I have the class below Person and it has a list of its dependents. My question is how to render this on the screen, let's say I have a table of people and when clicking on one another table of dependents is displayed, if there are many records it could cost the database a lot of time. How to do this to get better performance? In the example below, each time I get the Dependents of Person property, I search through a function for the Person id.
public class Dependent
{
public int Id { get; set; }
public string Name { get; set;}
}
public class Person
{
public int Id { get; set; }
public string Name { get; set;}
private List<Dependent> _dependents;
public List<Dependent> Dependentes
{
get {return _dependents = getDependentsForDatabase(this.Id);}
set { _dependents = value };
}
var dependents = new Person().Dependents;
Console.WriteLine(dependents);
I'm using Subsonic, but I'd like ideas regardless of the bank connection tool.
1.why not inherit from List?
2.How to Sort a List by a property in the object
3.What is the best way to give a C# auto-property an initial value?
4.How do I calculate someone's age based on a DateTime type birthday?
5.How can I retrieve Id of inserted entity using Entity framework?
Using
DbContext.Add()method withAsynchronousSaveChanges: If you're working withasynchronousoperations, you can useawaitDbContext.SaveChangesAsync()and then access the generated Id.6.What is the difference between a field and a property?
7.How do I view the
SQLgenerated by theEntity Framework?several options depending on the version of
Entity Frameworkyou're using and your development environment.8.How to set the Content-Type header for an
HttpClientrequest?9.How do I call a generic method using a Type variable?