I think I already know this is not possible, I haven't seen anything that allows me to do it, but I thought I would ask before admitting defeat.
I have 4 tables that are joined in a 1-*, *-*, *-*, *-1 relationship, I can query up these chains quite easily using the Any command to check the properties of each of the navigation properties, but what I am struggling with is the Include statement, when
I filter the first *-* on the properties on the 2nd *-*, the include statement returns all related entries on the first *-* not just the ones from my query.
How do I stop the include statement from returning these related but not involved in the query elements?
when I filter the first *-* on the properties on the 2nd *-*, the include statement returns all related entries on the first *-* not just the ones from my query.
Hello:)
If you only want the first *_*,I think that you maybe use something like the anoymous class(select new{……})to return all the fields that you want……
Slicksim
Participant
1925 Points
350 Posts
Linq to Sql Include
Jul 02, 2012 08:09 AM|LINK
Hi All,
I think I already know this is not possible, I haven't seen anything that allows me to do it, but I thought I would ask before admitting defeat.
I have 4 tables that are joined in a 1-*, *-*, *-*, *-1 relationship, I can query up these chains quite easily using the Any command to check the properties of each of the navigation properties, but what I am struggling with is the Include statement, when I filter the first *-* on the properties on the 2nd *-*, the include statement returns all related entries on the first *-* not just the ones from my query.
How do I stop the include statement from returning these related but not involved in the query elements?
Si
adamturner34
Contributor
3890 Points
971 Posts
Re: Linq to Sql Include
Jul 02, 2012 01:00 PM|LINK
What types of joins are you using?
Put the biggest resultset at the top of the query and and the smallest at the bottom.
Your resultset can be further filtered in the where clause.
Personally I would create a stored procedure or view and use Linq to query the result of that.
Slicksim
Participant
1925 Points
350 Posts
Re: Linq to Sql Include
Jul 03, 2012 07:51 PM|LINK
Thanks Adam,
I was trying my best to avoid using a stored proc and sticking to linq on the model.
If I could just lock down the navigation property to use the returned elements rather than all that would be awesome.
Si
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Linq to Sql Include
Jul 04, 2012 01:23 AM|LINK
Hello:)
If you only want the first *_*,I think that you maybe use something like the anoymous class(select new{……})to return all the fields that you want……