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