0

I want to reformat the data without going back to the database and in a dynamic way So that the user can specify what columns he wants to collect

how I can Write an sql string and execute it like EXECUTE IMMEDIAT in Oracle Inside C# Linq want to do a lock like combining two or more fields (multiply - merge...) ToTable It only allows me to specify the names of existing fields

FillDataSorce(params P)
{
  
  // p It is a variable containing the field to be queried
//Like

//field1 = d["field1"] ,
//field2 = d["field2"] ,
//field sum = d["field1"] +d["field2"]
 
 BSo.DataSource = from d in dt.AsEnumerable()
                    select new 
                    {
                       P.Select(p => p) //col3col2 = d["col1"] + d["col2"] Dynamic field example
                       
                    };
}
  • Your second code snippet isn't valid code, which never helps in asking a clear question. If I understand correctly, you have a data table of which you want to show columns the user can select. I think [this](https://stackoverflow.com/q/13760072/861716) is a duplicate. – Gert Arnold Feb 13 '22 at 09:45
  • Unfortunately, the example you showed I know, but it is not what I want because I want to do a lock like combining two or more fields (multiply - merge...) I want a sentence ToTable It only allows me to specify the names of existing fields – خالد بشير Feb 14 '22 at 07:53
  • Still not clear what you want. What is `classP`? Maybe you should show sample data and an output as you figure it should look like. – Gert Arnold Feb 14 '22 at 08:14
  • classP Array of a class containing the statement of the fields {name - field or fields and the operation between them} that I want to query – خالد بشير Feb 14 '22 at 08:41
  • Without knowing what `classP` is and how it is to be used, it is hard to answer. Provide more details. Consider using [LINQKit](https://github.com/scottksmith95/LINQKit) – NetMage Feb 14 '22 at 21:58
  • There is no classp significance The important thing is how I can query the query in a dynamic way There is no in LINQKit I don't want static fields for the query – خالد بشير Feb 15 '22 at 07:05

0 Answers0