say I have 2 columns, ColumnA and ColumnB from a table named TableAB,
with sets of data like this
ColumnA ColumnB
====== ======
12345 67890
54321 67809
...... ........
67890 abcde
67809 fghkm
....... .....
I would like to do a LINQ queries to give me results such that when the ColumnB values appear in ColumnA, then ColumnB gives the new values such that
Results
======
12345abcde
54321fghkm
Is this possible?
Appreciate if there is some code queries.
thanks.
Loading
Jignesh TrivediPosted Jul 11, 2013, 10:57 PM
hi,
If your class A like...
class TableA
{
public string ColumnA { get; set; }
public string ColumnB { get; set; }
}
try following code
List tableA = new List();
tableA.Add(new TableA { ColumnA = "12345", ColumnB = "67890" });
tableA.Add(new TableA { ColumnA = "54321", ColumnB = "67809" });
tableA.Add(new TableA { ColumnA = "67890", ColumnB = "abcde" });
tableA.Add(new TableA { ColumnA = "67809", ColumnB = "fghkm" });
var test = from a in tableA
join b in tableA on a.ColumnA equals b.ColumnB
select b.ColumnA + a.ColumnB;
foreach (var data in test)
{
Console.WriteLine(data);
}
hope this will help you.
TAN WhoAMIPosted Jul 11, 2013, 10:46 PM
Iftikar HussainPosted Jul 11, 2013, 10:14 AM
Regards,
Iftikar
TAN WhoAMIPosted Jul 11, 2013, 8:22 AM
Iftikar HussainPosted Jul 11, 2013, 5:24 AM
Regards,
Iftikar
TAN WhoAMIPosted Jul 11, 2013, 4:01 AM
thanks.
Iftikar HussainPosted Jul 11, 2013, 3:53 AM
Regards,
Iftikar
TAN WhoAMIPosted Jul 11, 2013, 3:41 AM
Iftikar HussainPosted Jul 11, 2013, 3:35 AM
What is the relation between these two table? Please provide more details.
Regards,
Iftikar