I have a design question related to Entity Framework objects.
I created the following object:
public class SomeEntity {
This object has 30 columns as an example. When I need to create a new object, this works fine. I have all the necessary fields to insert into the database.
I have several places in my application where I need to display some tabular data with some fields from SomeEntity, but I do not need all 30 columns, maybe only 2 or 3 columns.
Am I creating a completely new object that has only the fields that I need (which map to the same table as SomeEntity, but only retrieve the desired column?)
Or it makes sense to create a domain class (for example, PartialEntity) and write a query like this:
var partialObjects = from e in db.SomeEntities select new PartialEntity { Column1 = e.Column1, Column2 = e.Column2 };
I do not know how to do that. Is it nice to have two entities that map to the same table / columns? I would never need to create a PartialEntity and store it in the database, because it would not have all the fields that are required.
source share