views:

27

answers:

1

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 populate some fields of your POCO?

A: 

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.

Dr. Zim
We ended up selecting an anonymous type then using a for/next loop, moving the items in to the return type list.
Dr. Zim