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. how to write Dynamic select to get a value by custom operation between fields ?

how to write Dynamic select to get a value by custom operation between fields ?

Scheduled Pinned Locked Moved LINQ
csharptutorialdatabaselinqquestion
2 Posts 2 Posters 3 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.
  • A Offline
    A Offline
    amir hooshang
    wrote on last edited by
    #1

    Hi i have this code in sql i want to write it with linq in c# on a DatatTable i have CustomOperations table , so user can define custom operation between fields DECLARE @QueryToExecute varchar(max) DECLARE @SelectQuery varchar(max) SELECT TOP 1 @SelectQuery = [OperationString] FROM dbo.CustomOperations -- for example @SelectQuery = '([fee] + [amount]) * 50' or '[fee] * [amount] - [extraExpense]' defined by user SET @QueryToExecute = 'SELECT *,' + @SelectQuery + 'AS NewValue FROM MyTable' EXECUTE (@QueryToExecute) now i want to write it with linq in c# on a DatatTable to get value tnx

    D 1 Reply Last reply
    0
    • A amir hooshang

      Hi i have this code in sql i want to write it with linq in c# on a DatatTable i have CustomOperations table , so user can define custom operation between fields DECLARE @QueryToExecute varchar(max) DECLARE @SelectQuery varchar(max) SELECT TOP 1 @SelectQuery = [OperationString] FROM dbo.CustomOperations -- for example @SelectQuery = '([fee] + [amount]) * 50' or '[fee] * [amount] - [extraExpense]' defined by user SET @QueryToExecute = 'SELECT *,' + @SelectQuery + 'AS NewValue FROM MyTable' EXECUTE (@QueryToExecute) now i want to write it with linq in c# on a DatatTable to get value tnx

      D Offline
      D Offline
      Dan Mos
      wrote on last edited by
      #2

      In LINQ to SQL, the data model of a relational database is mapped to an object model expressed in the programming language of the developer. It doesn't work with data table but with objects that are maping a table or... Here's a fine introduction to LINQ to SQL.

      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