Query code is not duplicated

Source: Internet
Author: User

Public pagedlist<customerordermodel> getorderlistbystateconditional (string state, string conditional, int PageIndex, int pageSize)
{
pagedlist<customerordermodel> orderlist = new pagedlist<customerordermodel> ();
Try
{
using (var entity = new Dbautopartsentities ())
{
Order Status
var orderstate = Int. Parse (state);
Table Data
var list = (from T in entity. Tb_orderinfo
Join B in entity. Tb_customerinfo on T.customercode equals B.customercode
into S1
From X1 in S1. DefaultIfEmpty ()
where T.isdel = = "N" && (T.ordertype = = 1 | | t.ordertype = = 2)
Select New Customerordermodel
{
Ordercode = t.ordercode,//Order Code
Createtime = t.createtime,//creation time (time of order)
Orderprice = t.orderprice,//Order Amount
Orderstatus = t.orderstatus,//Order Status
CustomerName = x1. customername,//Customer Name
Telphone = x1. telphone,//Customer Phone
Mobilephone = x1. mobilephone,//Customer Phone
});
if (state = = "-1" && Conditional! = "")
{
List = list. Where (
t = t.ordercode.contains (conditional)
|| T.customername.contains (conditional)
|| T.telphone.contains (conditional)
|| T.mobilephone.contains (conditional));
}
else if (state! = "-1" && conditional = = "")
{
List = list. Where (t = = T.orderstatus = = orderstate);
}
else if (state! = "-1" && Conditional! = "")
{
List = list. Where (t = = T.orderstatus = = Orderstate
&& (t.ordercode.contains (conditional)
|| T.customername.contains (conditional)
|| T.telphone.contains (conditional)
|| T.mobilephone.contains (conditional));
}
Collection
OrderList = list. OrderByDescending (A = a.createtime). Topagedlist<customerordermodel> (PageIndex, pageSize);
Quantity per order
foreach (var item in Orderlist.data)
{
Number of items per order
int procount = 0;
A collection of each order item quantity
var pronum = entity. Tb_orderdetial.where (t = T.ordercode = = Item. Ordercode). Select (t = = t.productnum). ToList ();
foreach (Var proitem in Pronum)
{
Procount + = Proitem;
}
Item.productcount = Procount;
}
}
}
catch (Exception)
{

Throw
}
return orderlist;
}

Query code is not duplicated

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.