C#
C#

help

Root Question Message

kopuo
kopuo8/18/2022
Creating a new view or using unnecessary data?

Hi. I have a view made and used that returns 15 data fields to me. This view is already in use on the system in many places:
 var productData = await dbContext.ApiProductsView.AsNoTracking()
                .ToListAsync(cancellationToken);

Now I need to return 4 data fields that this view has. And the question is, will it be more optimal to use this ready view and remap only the necessary fields, or to create a new view only for these 4 data?
And would the following usage be correct and optimal?
 var productData = await dbContext.ApiProductsView.AsNoTracking()
                .Select(x => new ProductInfo
                {
                  field1 = x.field1,
                  field2 = x.field2,
                  field3 = x.field3,
                  field3 = x.field3
                })
                .ToListAsync(cancellationToken);
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy