c# - How to process data from 2 tables in database? -
i confused. followed tutorial:
i know how add don't know how add method , data 2 table not table. because result want have properties 2 tables. example:
customer:customerid,customername
order:orderid,customerid,orderdate
i want result:
customerid,customername,orderdate.
but confused because class customer , order different. don't know type of result should return can binding gridview. if it's customer type, orderdate don't have. , same order. please give me tip. thank in advance.
you can create new class represents result need service method. let's say:
public class mycustomerresult { public int customerid{get;set;} public string customername{get;set;} public datetime? orderdate{get;set;} }
and create method returns new class
public iqueryable<mycustomerresult> getmycustomerbylastname(string startinglastnameletter) { //you should modify query return data need, example var q = customer in this.objectcontext.customers order in this.objectcontext.orders c.customerid = o.customerid select new mycustomerresult { customerid=c.customerid, customername=c.customername, orderdate=o.orderdate } return q; }
Comments
Post a Comment