I'm trying to assign a variable to a select using LINQ.
My function which makes it evaluate a data set to get the SourceID according to the caption that has been passed into the select.
What I try to do is from an application in Windows Forms. The user when entering the value of this caption in a textBox, this value can be replaced by the existing value of the LINQ.
Here is my function:
private string GetMappingTable()
{
string SourceID = "";
var ds = GetMappingTable();
foreach (DataTable dst in ds.Tables)
{
foreach (DataRow dr in dst.Rows)
{
var DataSourceId = ds.Tables["Table"]
.Select("Caption = 'testUSers'")
.Select(r => r["SourceID"])
.Where(s => s != DBNull.Value)
.Select(s => s.ToString())
.FirstOrDefault();
SourceID = DataSourceId;
}
}
return SourceID;
}
I want that where .Select("Caption = 'testUSers'")
says the user from the texBox can enter another caption and that can be replaced.
Example:
In the select it says 'testUsers', if the user decides to put Users. This should be put in the value of the caption where it says testUsers.
How would you do that?
Thanks in advance.