Imagine the following situation there are 3 classes Class A, class B, class C, class A has many B classes and many C classes. class B has many C classes. the clsse C has a datetime date field.
public class A
{
DBContext db = new ClassesContext();
public IEnumerable<B> classesB{get; set;}
public IEnumerable<C> classesC{get; set;}
public IEnumerable<C> retornaTodasC()
{
var classes = ....
return classes;
}
}
public class B
{
public IEnumerable<C> classesC{get; set;}
}
public class C
{
public datetime Data;
}
As would be a search (made by class A) to the database using LINQ, order by, of all classes C of class A and classes C of each class B within that same class A, sorted by date and storing all classes 3 in a "var classes"?
Now imagine that class A is instantiated mtas times, and use this search a lot, what would be a good solution considering the "performance" in this case?