I’m using LINQ to Get data from database table called table1
when using LINQ a class called table1 was created
i created a partial class to add functionality to table1 class
public partial class Table1
{
public Table1(int id)
{
using (DBDataContext item = new DBDataContext())
{
var q = (from c in item.table1
where c.ID == id
select c).FirstOrDefault();
}
}
}
now i want to assign the result “q” to the current object
do i need to assign it’s properties one by one ?
or is there something faster??
Yes you need to assign it property by property, cause the result of your query is not an object, but
IEnumerable<..something..>of something. So you need to iterate over collection of values and assign them to corresponding properties of the object.EDIT
At this point I would do, like this:
and after use