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. Database & SysAdmin
  3. Database
  4. LINQ syntax

LINQ syntax

Scheduled Pinned Locked Moved Database
csharplinqquestiondiscussion
5 Posts 4 Posters 0 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.
  • V Offline
    V Offline
    vkEE
    wrote on last edited by
    #1

    Hi, For some reason no matter what I try, this syntax is erroring out.

    var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).ToList();

    It complains having a select or group by. I tried this as well, and it still errors.

    var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).Select().ToList();

    any thoughts?

    T Richard DeemingR 2 Replies Last reply
    0
    • V vkEE

      Hi, For some reason no matter what I try, this syntax is erroring out.

      var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).ToList();

      It complains having a select or group by. I tried this as well, and it still errors.

      var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).Select().ToList();

      any thoughts?

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      vkEmerson wrote:

      I tried this as well, and it still errors.

      What's that? always include those details in your questions. Besides you have posted your question in wrong forum. Try LINQ forum[^]. Now don't repost this question there, leave it now. Hereafter choose right forum.

      thatraja

      FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
      HTML Marquee & its alternatives

      Nobody remains a virgin, Life screws everyone :sigh:

      V 1 Reply Last reply
      0
      • T thatraja

        vkEmerson wrote:

        I tried this as well, and it still errors.

        What's that? always include those details in your questions. Besides you have posted your question in wrong forum. Try LINQ forum[^]. Now don't repost this question there, leave it now. Hereafter choose right forum.

        thatraja

        FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
        HTML Marquee & its alternatives

        Nobody remains a virgin, Life screws everyone :sigh:

        V Offline
        V Offline
        vkEE
        wrote on last edited by
        #3

        I could not find the LINQ forum, under the discussion. I will book mark the linq forum for future. if I try to get

        dispQuestions.Count

        , there is an error message,

        Error 5 Operator '>' cannot be applied to operands of type 'method group' and 'int'

        Syntax wise, am I missing the format? I am used to ADO.Net, and new to Linq. Trying to figure the various way to write it. Thanks.

        B 1 Reply Last reply
        0
        • V vkEE

          Hi, For some reason no matter what I try, this syntax is erroring out.

          var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).ToList();

          It complains having a select or group by. I tried this as well, and it still errors.

          var dispQuestions = (from m in demographicList.Where(o => o.customertype=="Patient")).Select().ToList();

          any thoughts?

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          The problem here is that you're mixing up the query syntax and the method syntax[^]. When the compiler is complaining that you're missing a select, it means that a query-syntax query must end with a select statement, but you've tried to fix it by adding a call to the Select method. Your query could be written in one of two ways:

          // Query syntax:
          var dispQuestions = (from m in demographicList where m.customertype == "Patient" select m).ToList();

          // Method syntax:
          var dispQuestions = demographicList.Where(o => o.customertype == "Patient").ToList();

          I tend to prefer the second option, but it's a purely aesthetic choice.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • V vkEE

            I could not find the LINQ forum, under the discussion. I will book mark the linq forum for future. if I try to get

            dispQuestions.Count

            , there is an error message,

            Error 5 Operator '>' cannot be applied to operands of type 'method group' and 'int'

            Syntax wise, am I missing the format? I am used to ADO.Net, and new to Linq. Trying to figure the various way to write it. Thanks.

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            Try dispQuestions.Count**()** instead.

            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