Last post Jul 03, 2020 06:47 AM by yij sun
Jul 02, 2020 09:33 PM|9peculiar|LINK
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
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")
ID = i.ID,
Startdate = i.Startdate,
Enddate = i.Enddate,
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),
Jul 03, 2020 06:47 AM|yij sun|LINK
but I wonder if I can also do the calculations in the respective repository .
As far as I think,you could add sum in the repository.However,I think,it's no impact on performance.
Besides,I think there are no best way to show data.You could put data which have getted into the cache.