Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Could someone help me out with this Linq query?

$
0
0

New to Linq and was wondering if someone could someone please help me out with this linq query.

The "test2" seems to just return the number of items regardless if the "Status" is filtered. Am I doing something wrong? I'm trying to create a query that pulls multiple tables, groups them and make multiple counts. This is what I am starting with now and will add the addition tables and counts as I get this to work.

from s in (
  from t in Cars
  join c in Clients on t.ClientId equals c.ID
  select new {t, c}
) group s by new { s.t.ClientId } into g
select new
{
	test1 = g.Select(x => x.c.Name),
	test2 = g.Select(x => x.t.Status == "Sold").Count()
}




Thanks!


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>