c# - Select and GroupBy -


itemprop = "text">

I have a table with the following fields

  id fk_siteID VisitDate  < / Pre> 

I want to write a query with LINQ which gives the number of records in a day with a specific SiteID , for example if citid = 1 Show me

  12.1.2014 6 13.1.204 8  

I have written this question

  on N = six Orderby g.FirstOrDefault () Visit Date in EntityFunctions.TruncateTime (a.VisitDate) in a db.CompanyWebsiteUsers in group one where g.FirstOrDefault (). Fk_siteID == Selecting SiteID New {key = g.Key, dayofweek = SqlFunctions.DateName ("day of the week", GK), calculation = g. Calculation ()}; GrdDailyRes.DataSource = n; GrdDailyRes.DataBind ();  

The result is that I have shown in this query: 2 records are in my table when that of the records in the VisitDate area with are the same Siteid = 1 and another citid = 2 . If websiteid is 1 or 2, then this query is already associated with them.

You only check the first item in a group, but you have to check other things as well. In simple solution db.CompanyWebsiteUsers where to carry the statement, i.e.

  on the N = one place where a.fk_siteID == EntityFunctions.TruncateTime (a.VisitDate) from the websiteID Group Orderbai Ji FirstOver Default (). VisitDate new selection  

Comments