Compte tenu de ce tableau:LinqToSQL - lire l'objet avec seulement certaines propriétés
Foo
P1
P2
P3
Comment puis-je lire Foo avec P1 seulement? Ma mise en œuvre:
public Foo GetFooWithP1(int id)
{
using (DbDataContext db = new DbDataContext())
{
var query =
from f in db.Foos
where f.Id == id
select new
{
P1 = m.P1
};
var data = query.SingleOrDefault();
return new Foo
{
P1 = data.P1
};
}
}
Y a-t-il des alternatives?
Merci, Marc, pour toi des allusions! Maintenant laissez-moi compliquer les choses :-) http://stackoverflow.com/questions/959417/linqtosql-read-objects-hierarchy-with-only-certain-properties – alex2k8