I have a complex SQL query which I need to run in LINQ. I'm wondering is it possible to do it with LINQ, or do I need anything else? Could you please help me? Thanks.
SELECT DISTINCT_PLAY_COUNT,SUM(1) AS CLIENT_COUNT FROM
(SELECT CLIENT_ID,SUM(1) AS DISTINCT_PLAY_COUNT FROM
(SELECT CLIENT_ID,SONG_ID FROM PIEXHIBIT
WHERE PLAY_TS >= '10/08/2016 00:00:00' AND PLAY_TS <= '10/08/2016 23:59:59'
GROUP BY CLIENT_ID,SONG_ID
)
GROUP BY CLIENT_ID
)
GROUP BY DISTINCT_PLAY_COUNT
Here is my class for it and what I accomplished so far;
public class Exhibit
{
public string PLAY_ID { get; set; }
public Int32 SONG_ID { get; set; }
public Int32 CLIENT_ID { get; set; }
public DateTime PLAY_TS { get; set; }
}
var sql = from Exhibit row in Exhibit
where row.PLAY_TS >= DateTime.Parse("10/08/2016 00:00:00") && row.PLAY_TS <= DateTime.Parse("10/08/2016 23:59:59")
select new { row.CLIENT_ID, row.SONG_ID };