Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DB table consists following Columns and Date.
HTML


Table1
id | CauseID(forgeinkey) | Datefrom | Title
-------------------------------------------
1 | 2 |09/10/2014 | title1
2 | 1 |09/20/2014 | title2
3 | 1 |09/20/2014 | title3
4 | 3 |09/30/2014 | title4
5 | 3 |09/30/2014 | title5


Table2
CauseID | Title
--------------------
1 | cause1
2 | cause2
3 | cause3

What i want that if user enters month 09 show the data from above table should be get in following format:

cause1(2)-title2-title3
(beacuse cause1 occures two times in Table in 09/20/2014)

cause3(2)-title4-title5
(beacuse cause3 occures two times in Table in 09/30/2014)

cause2(1)-title1
(beacuse cause2 occures one time in Table in 09/10/2014)

can somebody please tell me how to do it in linq asp.net
thank you very very much in advance
Posted

1 solution

In txt1 you can enter a date like 9/20/2014
DateTime dt = Convert.DateTime(txt1.Text);
var query = from T1 in context.Table1
join T2 in context.Table2 on T!.CauseID equals T2.CauseID
where SqiFunctions.DateDiff("DAY",T1.Dateform,dt) == 0
select new
{
T2.Title,
T1.Title
}


You will get two records and you need to do simple formatting in order to get result in above format
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900