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