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. WPF
  4. query using Lamda expression

query using Lamda expression

Scheduled Pinned Locked Moved WPF
databasecsharpcsslinqhelp
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.
  • P Offline
    P Offline
    picasso2
    wrote on last edited by
    #1

    Hello Listeners, I created a SL application (using C#) that returns contents of a table in SQL database. Table has 5 columns (FirstName, LastName, Age..etc). --A grid is populated with following: EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesQuery()); --Mine domain service has an entry as follows: public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } This works fine but What I am trying to do now is load only two columns at a time so I added this in the domain services public IQueryable GetTwoColms(string db1,string db2) { return this.ObjectContext.DBTables.Where(P => P.col1Name == cl1 && P.col2Name == cl2); } --And the main program, added this to a button action EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context. GetTwoColms Query("LastNames","FirstName")); It does not fail but it does not return anything either. Any help is greatly appreciated

    M K 2 Replies Last reply
    0
    • P picasso2

      Hello Listeners, I created a SL application (using C#) that returns contents of a table in SQL database. Table has 5 columns (FirstName, LastName, Age..etc). --A grid is populated with following: EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesQuery()); --Mine domain service has an entry as follows: public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } This works fine but What I am trying to do now is load only two columns at a time so I added this in the domain services public IQueryable GetTwoColms(string db1,string db2) { return this.ObjectContext.DBTables.Where(P => P.col1Name == cl1 && P.col2Name == cl2); } --And the main program, added this to a button action EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context. GetTwoColms Query("LastNames","FirstName")); It does not fail but it does not return anything either. Any help is greatly appreciated

      M Offline
      M Offline
      Matt T Heffron
      wrote on last edited by
      #2

      My first guess: You have the column names as "LastNames" (plural) and "FirstName" (singular) which looks suspiciously like a typo.

      P 1 Reply Last reply
      0
      • M Matt T Heffron

        My first guess: You have the column names as "LastNames" (plural) and "FirstName" (singular) which looks suspiciously like a typo.

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

        ThanX Matt, that is not the issue, it is just careless type when creating the post.

        L 1 Reply Last reply
        0
        • P picasso2

          ThanX Matt, that is not the issue, it is just careless type when creating the post.

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

          picasso2 wrote:

          it is just careless type when creating the post.

          Then use Copy & Paste, so what we see here matches exactly with what you have in your program.

          Veni, vidi, abiit domum

          1 Reply Last reply
          0
          • P picasso2

            Hello Listeners, I created a SL application (using C#) that returns contents of a table in SQL database. Table has 5 columns (FirstName, LastName, Age..etc). --A grid is populated with following: EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesQuery()); --Mine domain service has an entry as follows: public IQueryable GetDBTablesCompare() { return this.ObjectContext.DBTables; } This works fine but What I am trying to do now is load only two columns at a time so I added this in the domain services public IQueryable GetTwoColms(string db1,string db2) { return this.ObjectContext.DBTables.Where(P => P.col1Name == cl1 && P.col2Name == cl2); } --And the main program, added this to a button action EclipseMTXDomainContext context = new EclipseMTXDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context. GetTwoColms Query("LastNames","FirstName")); It does not fail but it does not return anything either. Any help is greatly appreciated

            K Offline
            K Offline
            koll Zhu
            wrote on last edited by
            #5

            u can use lamda method select() return a implicit class consists of u wanted 2 columns

            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