Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Linqtoentities syntax
Message
De
01/07/2010 15:50:36
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
01/07/2010 15:15:47
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01471213
Message ID:
01471240
Vues:
43
>>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});
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform