问题
I am trying to join two nav web services data using Linq query. But how can I do it. my code is as below.Suppose I have customer detail and its Invoice web service. and I want this detailin one page.Please give me solution.
public void bindEmpCustInvoice(string strCusCode)
{
List<Customer_Card_Filter> cardFilter = new List<Customer_Card_Filter>();
Customer_Card_Filter cardField = new Customer_Card_Filter();
cardFilter.Add(cardField);
Customer_Card[] cardList = cls.wsCustomerCard.ReadMultiple(cardFilter.ToArray(), null, 3);
RptEmpCustInvoise.DataSource = cardList;
RptEmpCustInvoise.DataBind();
decimal decValue = 0.00m;
List<Customer_Statistics_Bill_to_Customer_Filter> cFilter = new List<Customer_Statistics_Bill_to_Customer_Filter>();
Customer_Statistics_Bill_to_Customer_Filter cField = new Customer_Statistics_Bill_to_Customer_Filter();
cFilter.Add(cField);
Customer_Statistics_Bill_to_Customer[] billList = cls.wsCustBillService.ReadMultiple(decValue, decValue, decValue, decValue, cFilter.ToArray(), null, 3);
RptEmpCustInvoise.DataSource = billList;
RptEmpCustInvoise.DataBind();
var q = (from cd in cardList
join bd in billList on cd.No equals bd.No
orderby cd.No
select new
{
cd.No,
cd.Name,
cd.Contact,
cd.Phone_No,
cd.City,
bd.Balance_LCY,
bd.Outstanding_Orders_LCY,
bd.Shipped_Not_Invoiced_LCY,
bd.Outstanding_Invoices_LCY,
bd.Outstanding_Serv_Orders_LCY,
bd.Serv_Shipped_Not_Invoiced_LCY,
bd.Outstanding_Serv_Invoices_LCY
}).ToArray();
}
回答1:
By research, I found solution just bind linq result to Datasource. It is as below code.
public void bindEmpCustInvoice(string strCusCode)
{
try
{
Customer_Card[] cardList = cls.wsCustomerCard.ReadMultiple(null, null, 999999); Customer_Ledger_Entries[] billList = cls.wsCustInvoice.ReadMultiple(null,null,99999);
var q = (from cd in cardList
join bd in billList on cd.No equals bd.Customer_No
orderby cd.No
select new
{
cd.No,
cd.Name,
cd.Contact,
cd.Phone_No,
cd.City,
bd.Amount });
RptEmpCustInvoise.DataSource = q.ToList();
RptEmpCustInvoise.DataBind();
}
catch { throw; }
}
来源:https://stackoverflow.com/questions/39407688/join-two-nav-web-services-data-in-one-repeater