Aggregation count returns null in linq asp.net core
-
I'm implementing asp.net core 3.1 project. In my controller I have a linq query like the following and without defining inprocessapicount and pendingcount which claculates counts of related amounts, it works fine but after adding them to my query in select part, applicants returns null. I appreciate if anyone suggests me a solution. var applicants = (from t1 in _context.VwDesk { apiID = t1.ApiId, applicantID = t1.ApplicantId, applicantName = t1.ApplicantName, gateName =t1.GateName, requestStatus = t1.LastReqStatus } group tg by new { tg.requestStatus,tg.apiID ,tg.applicantID, tg.applicantName} into ApiAppGp select new { applicantName = ApiAppGp.Key.applicantName, apiname = ApiAppGp.Key.apiID, apicount =ApiAppGp.Count(), inprocessapicount = ApiAppGp.Where(a => a.requestStatus == "bb").Count(), pendingapicount = ApiAppGp.Where(a => a.requestStatus == "aa").Count() }).ToList();
-
I'm implementing asp.net core 3.1 project. In my controller I have a linq query like the following and without defining inprocessapicount and pendingcount which claculates counts of related amounts, it works fine but after adding them to my query in select part, applicants returns null. I appreciate if anyone suggests me a solution. var applicants = (from t1 in _context.VwDesk { apiID = t1.ApiId, applicantID = t1.ApplicantId, applicantName = t1.ApplicantName, gateName =t1.GateName, requestStatus = t1.LastReqStatus } group tg by new { tg.requestStatus,tg.apiID ,tg.applicantID, tg.applicantName} into ApiAppGp select new { applicantName = ApiAppGp.Key.applicantName, apiname = ApiAppGp.Key.apiID, apicount =ApiAppGp.Count(), inprocessapicount = ApiAppGp.Where(a => a.requestStatus == "bb").Count(), pendingapicount = ApiAppGp.Where(a => a.requestStatus == "aa").Count() }).ToList();
Query's too "complicated" for anyone to bother with. Need to break it down with intermediate queries and results that you can "debug". "Big" queries are a sign of laziness; not sophistication. LINQ is no smarter than the person wielding it.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
I'm implementing asp.net core 3.1 project. In my controller I have a linq query like the following and without defining inprocessapicount and pendingcount which claculates counts of related amounts, it works fine but after adding them to my query in select part, applicants returns null. I appreciate if anyone suggests me a solution. var applicants = (from t1 in _context.VwDesk { apiID = t1.ApiId, applicantID = t1.ApplicantId, applicantName = t1.ApplicantName, gateName =t1.GateName, requestStatus = t1.LastReqStatus } group tg by new { tg.requestStatus,tg.apiID ,tg.applicantID, tg.applicantName} into ApiAppGp select new { applicantName = ApiAppGp.Key.applicantName, apiname = ApiAppGp.Key.apiID, apicount =ApiAppGp.Count(), inprocessapicount = ApiAppGp.Where(a => a.requestStatus == "bb").Count(), pendingapicount = ApiAppGp.Where(a => a.requestStatus == "aa").Count() }).ToList();
Textbook guides are essential aids for any college course or discipline. All manners of learning from exam preparation or projects and assignments to self-study becomes easier with a collection of well-prepared textbook solutions. ScholarOn offers the best accounting textbook solution guides online like Solutions For Advertising And Promotion An Integrated Marketing 10th Edition .