开发者

Entity Framework 4 Repository returning IList: What C# code could limit which POCO fields populate?

开发者 https://www.devze.com 2023-01-20 23:58 出处:网络
If you populate a drop down list of possible values, you only want the database query to pull two fields, a value and text (like customer ID and Name).

If you populate a drop down list of possible values, you only want the database query to pull two fields, a value and text (like customer ID and Name).

However, your Repository returns POCOs, namely the entire Customer record.

I wouldn't think you should create a POCO for every single DDL list you need, so how does one specify to a repository what fields to populate using Entity Framework 4, ASP.NET POCO generator, and a repository that doesn't return IQueryable or IEnumerable (doesn't defer the SQL call when leaving the repository)?

Simply put, how do you inform the repository to only populat开发者_JS百科e some fields of your POCO?


I bet you could use an internal class to pull out different content, then AutoMap them to your Domain Models before you leave the Repository. It would mean duplicating classes though.

Otherwise you could return IQueryable from your Repository, which has all kinds of problems, like querying a set of data when you .Count then again when you use the data.

0

精彩评论

暂无评论...
验证码 换一张
取 消