Nested Select queries i main select query LINQ
-
apologized for asking a help for linq query. i hardly use LINQ rather i use MSDAAB as DAL which i use to execute my inline sql query or my db store procedure etc. now i am in situation where i need to use LINQ to extract data from datatable. here i am attaching one screenshot like how my data look like enter image description here http://i.stack.imgur.com/NMrvR.png[^] the is data is coming from sql server and for which i am using the below query for sql server. please see my query first. select (select count(*) as incoming from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name='Train5') as incoming, (select count(*) as OutGoing from tridip_Interval where direction='O' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and party1name not in ('Voice Mail') and party1name='Train5') as OutGoing, (select count(*) as CallTransfer from tridip_Interval where continuation=1 and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name not in ('Voice Mail') and party1name='Train5') as CallTransfer, (SELECT count(*) as UnansweredCalls_DuringBusinessHours from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)= '00:00:00' and [Ring duration]>0 and party1name='Train5') as misscall now i want to use LINQ to query data table but hence i am not good in linq so not being able to compose the above sql like query with linq. so just wonder if any guy help me to compose the above query with linq. apologized could not highlight my linq query because very honestly i know linq little and that is the reason things is not coming to my mind how to compose the same above sql query with LINQ. looking for hep and support.
tbhattacharjee
-
apologized for asking a help for linq query. i hardly use LINQ rather i use MSDAAB as DAL which i use to execute my inline sql query or my db store procedure etc. now i am in situation where i need to use LINQ to extract data from datatable. here i am attaching one screenshot like how my data look like enter image description here http://i.stack.imgur.com/NMrvR.png[^] the is data is coming from sql server and for which i am using the below query for sql server. please see my query first. select (select count(*) as incoming from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name='Train5') as incoming, (select count(*) as OutGoing from tridip_Interval where direction='O' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and party1name not in ('Voice Mail') and party1name='Train5') as OutGoing, (select count(*) as CallTransfer from tridip_Interval where continuation=1 and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name not in ('Voice Mail') and party1name='Train5') as CallTransfer, (SELECT count(*) as UnansweredCalls_DuringBusinessHours from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)= '00:00:00' and [Ring duration]>0 and party1name='Train5') as misscall now i want to use LINQ to query data table but hence i am not good in linq so not being able to compose the above sql like query with linq. so just wonder if any guy help me to compose the above query with linq. apologized could not highlight my linq query because very honestly i know linq little and that is the reason things is not coming to my mind how to compose the same above sql query with LINQ. looking for hep and support.
tbhattacharjee
Hi, Here is the link which shows how to get count from LINQ query. http://stackoverflow.com/questions/3853010/get-item-count-of-a-list-using-linq[^] Here is link that shows how to query Datatable using LINQ: Working with LINQ to Entities & LINQ to DataTable[^]
-
Hi, Here is the link which shows how to get count from LINQ query. http://stackoverflow.com/questions/3853010/get-item-count-of-a-list-using-linq[^] Here is link that shows how to query Datatable using LINQ: Working with LINQ to Entities & LINQ to DataTable[^]
basically i would have a main select and there will be some nested select like below
SELECT EmployeeName,
(Select count(*) from table1 where condition) as data1,
(Select count(*) from table1 where condition) as data2,
(Select count(*) from table1 where condition) as data3i like to know how to write nested select ? anyone can construct a sample one for me. thanks
tbhattacharjee