Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I need to know how to fetch entities, but only with a part of properties, not the whole entity. I used to invoke DbContext.Set<tentity>().QuerySql(), but it fails to construct a proper entity since it needs ALL the entity properties in an internal data reader. How to get only partial entities?
Posted
Updated 6-Mar-15 14:16pm
v2

1 solution

You don't. In EF you only get the entire entity stored in the database re-hydrated in the DbContext tacker.

You can use projection to get just the properties you need copied into another object, but the database is still going to return the entire entity record and the DbContext is still going to track every property of the entity that came back.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900