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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -