return from a linq where statement

Posted by Vaccano on Stack Overflow See other posts from Stack Overflow or by Vaccano
Published on 2010-03-11T20:55:54Z Indexed on 2010/03/11 20:59 UTC
Read the original article Hit count: 482

Filed under:
|
|
|

I have the following link function

MyLinqToSQLTable.Where(x => x.objectID == paramObjectID).ToList();

I most of the time you can change a linq call to be several lines by adding curly brackets around the method body. Like this:

MyLinqToSQLTable.Where(x =>
{ 
    x.objectID == paramObjectID;
}).ToList();

Problem is the implied return that was there when I just did a Boolean compare is now not done. Return (x.objectID == paramObjectID); is not accepted either.

How do do this? can I do this?

NOTE: I know that I can add another where clause if needed. But I would still like to know the answer to this.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ