tbl_TransType:
ID int Unchecked
TransTypeID int Unchecked
TransType nvarchar(1000) Checked
and
tbl_TransactionsUsers:
ID int Unchecked
UserId uniqueidentifier Checked
Amount decimal(18, 2) Checked
Date datetime Checked
TransType int Checked
TransReference nvarchar(1000) Checked
In the table tbl_TransType I have
Id, TransType, TransTypeId
1, Visa, 1
In other table tbl_TransactionsUsers I have
Amount, Date, TransType,
10, 8/11, 1,
So, now I would like to show instead of 1 (TransType from second table), data from first tables: Visa.
My gridview like this:
Amount, Date, TransType
10, 8/10, Visa
how do join between these tables? Does that ID? give full details of tbl_TransactionsUsers also give more example data...
anyhow, following example gives to result from table2, and based on table 1 ID == 10
var myLINQ = from t1 in tbl_TransType.AsEnumerable()
join t2 in tbl_TransactionsUsers.AsEnumerable() on t1.Field<int>("ID") equals t2.Field<int>("ID")
where t1.Field<int>("ID") == 10
select new
{
Amount = t2.Field<decimal>("Amount"),
Date = t2.Field<DateTime>("Date"),
TransType = t2.Field<int>("TransType"),
};
programercek
Participant
1507 Points
2213 Posts
two tables with linq
Aug 10, 2012 10:26 PM|LINK
Hi,
I have two tables.
tbl_TransType:
ID int Unchecked
TransTypeID int Unchecked
TransType nvarchar(1000) Checked
and
tbl_TransactionsUsers:
ID int Unchecked
UserId uniqueidentifier Checked
Amount decimal(18, 2) Checked
Date datetime Checked
TransType int Checked
TransReference nvarchar(1000) Checked
In the table tbl_TransType I have
Id, TransType, TransTypeId
1, Visa, 1
In other table tbl_TransactionsUsers I have
Amount, Date, TransType,
10, 8/11, 1,
So, now I would like to show instead of 1 (TransType from second table), data from first tables: Visa.
My gridview like this:
Amount, Date, TransType
10, 8/10, Visa
Please help
Mastan Oli
Contributor
5088 Points
998 Posts
Re: two tables with linq
Aug 10, 2012 10:38 PM|LINK
how do join between these tables? Does that ID? give full details of tbl_TransactionsUsers also give more example data...
anyhow, following example gives to result from table2, and based on table 1 ID == 10
var myLINQ = from t1 in tbl_TransType.AsEnumerable() join t2 in tbl_TransactionsUsers.AsEnumerable() on t1.Field<int>("ID") equals t2.Field<int>("ID") where t1.Field<int>("ID") == 10 select new { Amount = t2.Field<decimal>("Amount"), Date = t2.Field<DateTime>("Date"), TransType = t2.Field<int>("TransType"), };playingOOPS | மெய்ப்பொருள் காண்பதறிவு
Mark as Answer If you find helpful