Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Linqtoentities syntax
Message
From
01/07/2010 15:50:36
John Baird
Coatesville, Pennsylvania, United States
 
 
To
01/07/2010 15:15:47
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 4.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01471213
Message ID:
01471240
Views:
44
>>When using EF 4, MM 4, VS2010 and the following LINQ query in MM biz tier,
>>
>> IQueryable<ClientEntity> query = from o in this.ObjectContext.ClientEntities
>>                                                             select o;
>>            return this.GetEntityList(query);
>>
>>what is the syntax to bring back a subset of fields,
>>select new {o.FirstName, o.LastName}; doesn't work; however, the foreach analysis does, but that is not what I want to return.
>>It gives me an error that I am trying to implicitly cast an anonymous type to my 'MM entity' type and implies that there is a specific cast for this, I don't know what this would be. I really don't want to bring back a large number of fields when I only need a few. Maybe I have to build a separate EF class for just this purpose but it seems like a waste. I couldn't find anything on this in the MM Guide.
>>Thanks for any help!
>
>You could simplify this and use Stored Procedure that only returns what you want. This is more of an Linq to Entity question than a MM one I think. Maybe someone with more Linq experience will jump in and give you the syntax needed.
>Tim


from o in this.ObjectContext.ClientEntities.Select(o=>new {myfield = o.datafield, myfield2 = o.datafield2});
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform