As the other answers pointed out, you need to use an anonymous type.
Regarding the syntax, I personally prefer the chaining method. The equivalent of a chain of methods would be: -
var employee = _db.EMPLOYEEs .Where(x => x.EMAIL == givenInfo || x.USER_NAME == givenInfo) .Select(x => new { x.EMAIL, x.ID });
AFAIK, the declarative LINQ syntax is converted to a chain of method calls similar to this during compilation.
UPDATE
If you need the whole object, you just need to omit the Select() call, i.e.
var employee = _db.EMPLOYEEs .Where(x => x.EMAIL == givenInfo || x.USER_NAME == givenInfo);
Adam Ralph Jul 21 '11 at 6:52 2011-07-21 06:52
source share