Entity Framework Count Parent rows that have a child record with a constraint -


i have parent , child table. 1 many relationship. trying determine way count number of parent records have child record constraint on both child , parent.

example: count number of parent records created today , have child record value of true in in address column.

i stumped.

(from p in context.parents p.createdon.date == datetime.now.date && p.children.any(c=>c.address != null) // or p.children.any(c=>c.address == true) select p).count() 

may this?

you can go children, example:

(from c in context.child c.address == true && c.parent.createdon.date == datetime.now.date select c.parent).distinct().count() 

in lambda expression, please note used childobj.address == true (most condition bit different, should see idea.

  context.arc_records                       .where(d => (d.signed == false || d.signed == null)                              && d.childobject.any(c=>c.address == true))                      .count(); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -