Skip to content

Tag: linq

Convert Sql to linq with groupby

I have view on which I use this request And it’s running sucessfully and get me this data How I need to write it using linq to get same data? I tried like this But on new HumpChartDto() {SpendBand = x.SpendBand} I got Cannot resolve symbol ‘SpendBand How I can solve this? Answer First, after grouping on SpendBand, you need

Return IEnumerable rather IEnumerable

I need to join two tables and get the data from one of the table using linq. The join works fine but it returns IEnumerable <$IEnumerable><$Ojbect> and I need IEnumerable<$Object> Here is the code: Thanks Answer In general, when you want to “flatten” a collection, SelectMany is the construct you’re looking for. In LINQ Query Syntax, that’s accomplished with multiple

linq query to get possible combinations

I have table1 like funid reasonid 1 1 1 2 2 1 2 3 and users table(users will repeat) like below userid reasonid 10 1 10 2 11 1 12 3 13 1 13 3 how to write a query to get the users satisfying table 1 combination {1,2} and {1,3}, so as per the above data userid 10 and

I didn’t true use order by in linq

Hi i develop web app with c#. I have sql query and i convert to linq but it’s not working true because of order by My sql query My linq Answer Here’s how you can do the order by on the count of each group and take the 3 with the highest count.

How do I translate this specifik SQL statement to LINQ

SQL: C# Objects: Monitor: And Counter: And the objects that I need to turn it into is: AllStatistics: I don’t have much experience with LINQ so the most I’ve achieved with it is somethig like: My question is, how would I compose an LINQ statement with the same functionality of the above SQL query ? Answer It looks like you

Linq Find the most recurring record

I have a rent a car project. This is the table where I keep the rented vehicles I want to find the most rented vehicle in this table. How can I do this? So I want to find the most mentioned car Id in the table [I have to do it with context architecture. How can I do this with