Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Aggregation count returns null in linq asp.net core

Aggregation count returns null in linq asp.net core

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpasp-netdatabasedotnetlinq
3 Posts 3 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElenaRez
    wrote on last edited by
    #1

    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();

    L M 2 Replies Last reply
    0
    • E ElenaRez

      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();

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • E ElenaRez

        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();

        M Offline
        M Offline
        Member_14936319
        wrote on last edited by
        #3

        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 .

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups