You use include when you want the data for a related table to be included. So for example you were using the entity framework to pull a table from the northwind database. If you were querying the orders table you would need to use include to get the orderdetails loaded
when the data is gotten from the database instead of when you use it.
amodius
Member
178 Points
383 Posts
how to select many tables on anonymous query
Apr 24, 2012 05:07 PM|LINK
hi there
i have the follow linq query:
<div>ctx.Contact.Include("Interlocutor").Include("ASI..Include("Attacth").include("customers") .Where(c => idOKRAM == null || c.check_ram == idOKRAM)</div>how can i have an anonymous type?
if i write:
select new {d=>d.name..}
returns the data only from 1 table!
i need return from more table..how can i do?
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: how to select many tables on anonymous query
Apr 24, 2012 06:46 PM|LINK
You would have to do a Linq join to get data from more than one table
http://msdn.microsoft.com/en-us/library/bb311040.aspx
Space Coast .Net User Group
amodius
Member
178 Points
383 Posts
Re: how to select many tables on anonymous query
Apr 24, 2012 07:23 PM|LINK
my manager suggested to use .Include("table") function
yes. i've seen the link above, thanks a lot
can you tel me if it is better use .Include than join?
thank you
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: how to select many tables on anonymous query
Apr 24, 2012 08:09 PM|LINK
You use include when you want the data for a related table to be included. So for example you were using the entity framework to pull a table from the northwind database. If you were querying the orders table you would need to use include to get the orderdetails loaded when the data is gotten from the database instead of when you use it.
Space Coast .Net User Group