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. LINQ
  4. cutom query

cutom query

Scheduled Pinned Locked Moved LINQ
helpcssdatabase
6 Posts 3 Posters 14 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.
  • P Offline
    P Offline
    picasso2
    wrote on last edited by
    #1

    I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated

    D B 2 Replies Last reply
    0
    • P picasso2

      I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated

      D Offline
      D Offline
      dasblinkenlight
      wrote on last edited by
      #2

      If you would like to get only the groupId column, you need to use Select(t => t.groupId). Include("EntityName1.EntityName2...") instructs EF to include data from another table, that is directly or indirectly linked to the one you're querying.

      P 1 Reply Last reply
      0
      • P picasso2

        I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Read more about Include function in EF.[^]


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

        1 Reply Last reply
        0
        • D dasblinkenlight

          If you would like to get only the groupId column, you need to use Select(t => t.groupId). Include("EntityName1.EntityName2...") instructs EF to include data from another table, that is directly or indirectly linked to the one you're querying.

          P Offline
          P Offline
          picasso2
          wrote on last edited by
          #4

          I could not complete the return statement as your suggestion: public IQueryable<compntMtx> GetCompntMtxes(int components) { return this.ObjectContext.compntMtxes.Select(t =>t; t.compName)?? } I cannot add an "Include" after the select (e.g. Select(t =>t;t; t.compName).Include(myEntityName) thank you in advance for the help

          D 1 Reply Last reply
          0
          • P picasso2

            I could not complete the return statement as your suggestion: public IQueryable<compntMtx> GetCompntMtxes(int components) { return this.ObjectContext.compntMtxes.Select(t =>t; t.compName)?? } I cannot add an "Include" after the select (e.g. Select(t =>t;t; t.compName).Include(myEntityName) thank you in advance for the help

            D Offline
            D Offline
            dasblinkenlight
            wrote on last edited by
            #5

            If you are building a projection that returns a single column, the return type of your method would be IEnumerable<MyColumnType>, not IQueryable<compntMtx>. You do not need to use "Include" at all.

            P 1 Reply Last reply
            0
            • D dasblinkenlight

              If you are building a projection that returns a single column, the return type of your method would be IEnumerable<MyColumnType>, not IQueryable<compntMtx>. You do not need to use "Include" at all.

              P Offline
              P Offline
              picasso2
              wrote on last edited by
              #6

              thank you dasblinkenlight for your suggestion, the problem is that I have a table with 7 columns but just want to display only 4 of them

              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