MVC Core Data Access Naming Convention Folder vs Repository

by BlueLamp82   Last Updated May 28, 2018 09:05 AM

We have Customer transaction table with many foreign key relationships.

We only want to see certain columns of the 3 tables joined in a web interface.

Eg just Date, PurchaseAmount, ProductName, and StatusDescription.

I hear repository should not select certain columns, it should select All columns. So we should not use repository below. If reading all columns or too many related tables, sql query can slow down with unoptimized data.

What should I name this new data access method?

Additionally, should I create own folder for this, I already have a Repository folder., should I create another folder for WebRepository?

CustomerTransactionWebRepository instead of CustomerTransactionRepository?

Repository:

public class CustomerTransactionRepository: ICustomerTransactionRepository{
    public CustomerTransaction GetCustomerTransaction(int CustomerTransactionId ) 
    {
        var result = context.CustomerTransaction.Where(c=>c.CustomerTransactionId == id)
         .Include(p=>p.ProductType)
         .Include(s=>s.StatusType);
    }


public class CustomerTransactionWebServiceRepository: IWebServiceRepository 
{
    public CustomerTransaction GetCustomerTransaction(int CustomerTransactionId ) 
        {
            var result = context.CustomerTransaction.Where(c=>c.CustomerTransactionId == id)
             .Include(p=>p.ProductType)
             .Include(s=>s.StatusType);
              .Select(p => new {
                      DateOfPurchase= c.DateOfPurchase, 
                      PurchaseAmount= c.PurchaseAmount, 
                      ProductName= p.ProductName
                      StatusDescription = s.StatusDescription
        }

Model sample:

public class CustomerTransaction
{
    public int CustomerTransactionId { get; set; }
    public string DateOfPurchase{ get; set; }
    public int PurchaseAmount { get; set; }

    // relationships
    public ProductType ProductType { get; set; }
    public int ProductTypeId { get; set; } 

    public StatusType StatusType { get; set; }
    public int StatusID { get; set; }  
}


Related Questions



Table Per Concrete Type in Entity Framework Core

Updated November 14, 2017 01:05 AM

Should it be a claim, a role or a policy?

Updated September 25, 2018 07:05 AM

Which data should be stored as `Claim`?

Updated December 02, 2017 00:05 AM