Reputation: 2295
I am new to Linq and EF; my project is in MVC3. I am tyring to do a Select, and would like to add (Where or if) to exclude a record when specific item value is less than 1. Here is my script
.Select(item => new AreaModel
{
ID = item.ID,
Name = item.Name,
PersonID = item.PersonID,
}) ;
In this case if the PersonID is less than 1 exclude this record. Thanks in advance
Upvotes: 2
Views: 6931
Reputation: 2683
A good starting point for LINQ are the 101 LINQ samples http://msdn.microsoft.com/en-us/vcsharp/aa336746
Happy LINQ'ing
Upvotes: 1
Reputation: 11987
you should basically end up with something like:
EntityObject.Where(x => x.PersonID >= 1)
.Select(item => new AreaModel
{
ID = item.ID,
Name = item.Name,
PersonID = item.PersonID,
});
Upvotes: 1