-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select<TKey>(Expression<Func<T, TKey>> fields) method question #52
Comments
Projections in NPoco are implemented to only select certain columns for an entity. eg. public class User {
public int Id {get;set;}
public string Name {get;set;}
public byte[] Avatar {get;set;}
} For instance, if I had the above User but I didn't want to select the Avatar this time, I could run. db.FetchBy<User>(sql => sql.Select(x=> new { x.Id, x.Name })) This is still based on the User object, so that if I then needed a where I could. db.FetchBy<User>(sql => sql.Select(x=> new { x.Id, x.Name }).Where(x=>x.Avatar == null) If it returned Does this make sense? |
Yep, makes sense. What I've done in my repository class is add the db.FetchBy(sql => sql.Select(x=> new { x.Id, x.Name }).Where(x This gives me precisely what I want -- a Linq-like behaviour (so I can keep On Wed, Nov 27, 2013 at 7:19 PM, Adam Schroder notifications@github.comwrote:
Tim P.S. If you have trouble reaching me at tim@askerov.net |
Cool. |
Hi,
This is more of a question than an issue report:
Method
Select<TKey>(Expression<Func<T, TKey>> fields)
returnsSqlExpression<T>
but shouldn't it returnSqlExpression<TKey>
instead?I.e. if I am doing a projection like
.Select(x => new { ID = x.ID, Name = x.Name })
then the result should be an expression of the anonymous type TKey, right? At least that's how it works in Linq.Can you comment on that please?
P.S. Just as a background: I am working on a common repository interface that can support both NPoco- and EF-based concrete repositories, and this is one of the requirements.
The text was updated successfully, but these errors were encountered: