Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Best approach to show related aggregated database data in EFF

$
0
0

Hi  there:

I'm showing in a jqgrid  complex queries from a database. Though the performance is okay as I don't retrieve all the data at once and the paging, sorting and search is performed in the server side, I want to know whether there is a more efficient way to do it.

The code below shows that I have encapsulated all the BLL  in repositories and  put the data into an anonymous type which  I think is the correct way to  join and query related data, but I wonder if I can also do the calculations in the respective repository . My doubt is if this read-only calculated properties will play havoc with my CRUD as I read that the database  won't recognize these properties . I read also that EFF has work- arounds about calculated properties   but I want to know whether there is a most efficient way than this ...I want to be a better programmer. 

For your ease of reference , I attached the query ...as I said, it works fine but I'd like to know whether 

public JsonResult Contracts_Expenditure_per_financial_year_List()
{

var Contract_List = from i in db.Contractrepository.Getlist(includeProperties: "Company")
select new
{
ID = i.ID,
i.IdCompany,
i.Contractdescription,
i.ContractValue,
Startdate = i.Startdate,
Enddate = i.Enddate,
i.Company.Companyname,
FY20182019= db.Invoicerepository.Getlist(includeProperties: "Contract_Amounts", filter: y => y.Contract_Amounts.IdContract == i.ID && y.Financialyear==19).Sum(j => j.Workdone),
FY20192020 = db.Invoicerepository.Getlist(includeProperties: "Contract_Amounts", filter: y => y.Contract_Amounts.IdContract == i.ID && y.Financialyear == 20).Sum(j => j.Workdone),

i.Total,
i.Contigencies

};


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>