I wonder if there is a better solution to my problem then this one https://entityframeworkcore.com/knowledge-base/44877455/get-all-columns-except-one-in-efcore
I have several models with many columns (lets say 20) and few columns are heavy - blobs. Naturally, I would like to have a method retrieving the data (list of them) in a light way - i.e. excluding these few columns. So far the only method working is the one proposed in the link above, i.e.
original model:
{
public Rating() { }
public int IdRating { get; private set; }
public string IdUser { get; set; }
public decimal Value { get; private set; }
public string Comment { get; private set; }
public bool IsEnabled { get; set; }
public int IdCorrespondent { get; private set; }}
then the lighter version
public class RatingView
{
public Rating() { }
public int IdRating { get; private set; }
public decimal Value { get; private set; }
}
and the data retrieval is
public List<RatingView> ListRatings()
{
return _context.Ratings.Select(x => new RatingView
{
IdRating = x.IdRating ,
Value = x.Value ,
}).ToList();
}
the first problem is that there are too many columns to set this way and secondly there are several similar classes, so the solution is not really nice and error prone for future changes of the models. Automapper looks like a nice approach but the queries generated are not optimal - all columns are retrieved.
Thanks, arbus