Given such table:
Foo
P1
P2
P3
How can I read Foo with P1 only? My implementation:
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
};
}
}
Are there any alternatives?