I have something like this:
class SomeClass
{
public int Id {get;set}
public int someProperty1 {get;set;}
public int someProperty2 {get;set;}
public string someProperty3 {get;set;}
public List<SomeObject> SomeObjects {get;set}
}
When I want to get properties of this class, I do:
var db = new SomeClass();
var myClass = db.SomeClass.Single(class => class.Id == 1);
And it works perfectly fine, I can get all the properties, but the List<SomeObject> property is always null. How can I get a single myClass object, that does have all the properties, AND a list of SomeObjects? I know that I can do it like that:
var myList = db.SomeClass.SomeObjects.Single(...);
But I do not want to do it that way, is there any other way of getting WHOLE object at once?
If you are using Entity Framework, you can include a related table using the Include method. See the documentation here.