Ado.net entity framework using count in a where clause?

You could try moving the taskItem.Velocities.Count() inside the select new { } Then do a select on the resultant list where the velicties count == 0.

This is what I did... at this point my application is well behaved if a little sub-optimal. – Pieter Breed Jul 7 '09 at 6:40.

You need to have joins to reflect the relationships, currently you are doing a cartesian (cross) join (i.e. All combinations of project, task and taskItem). Try something like: var res = from project in db.

Projects where project. Id == pProjectId join task in project. Tasks on task.

ProjectId equals project. ProjectId join ttaskItem in task. TaskItems on taskItem.

TaskId equals task. TaskId where taskItem.Velocities.Count() == 0 // not finished yet select new { ProjectId = pProjectId, PriorityId = task.Priorities. Id, TaskId = task.Id, ResourceId = taskItem.Resources.

Id, EstimatedDuration = taskItem. EstimatedDuration, TaskItemId = taskItem.Id }.

1 I don't believe this is the right answer. The 'from task in project. Tasks' actually performs an inner join so I believe if I did what you suggest it would actually have to be 'join task in db.

Tasks' &c in which case I'd be creating a join which I can get for free. Besides... It gives the exact same (wrong) results :/ thanks though! – Pieter Breed Jul 6 '09 at 13:10 You can also do a left outer join with: ... join r in source on r.

Prop equals other. Prop into rows. But without knowing more of your data model hard to be specific.(Just checking for taskItems having more than one velocity is correct in your original.) – Richard Jul 6 '09 at 15:19.

The Entity model is querying your database to retrieve those values, if you are adding data to the entities BUT had not saved them to the db, the query can't know about those new values. Try db.SaveChanges() before the query.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions