Var results = db.tblForumAuthors. GroupBy(r => new {Year = r. Join_date.
Year, Month = r. Join_date. Month}) .
Select(g => new {Registrations = g.Count(), g.Key. Year, g.Key. Month}) .
OrderBy(r => r. Year) . ThenBy(r => r.
Month).
Thanks! This seems to make red squiggly lines though ` 'System.Linq. IGrouping' does not contain a definition for 'Year' and no extension method 'Year' accepting a first argument of type 'System.Linq.
IGrouping'` – Tom Gullen Jul 5 at 20:35 see my answer above, in second line g. Year should be g.Key. Year – valipour Jul 5 at 20:37 Super thanks!
You have an invalid semicolon btw though, but seems to work great otherwise :D – Tom Gullen Jul 5 at 20:39 1 @Tom I didn't see @valipour's answer but our answers are pretty much the same. I was missing . Key in the query.
I have edited the answer or just refer to the other answer. – Bala R Jul 5 at 20:39.
From c in db. TblForumAuthors group c by new {month = t. Join_Date.
Month, year = t. Join_Date. Year} into g select new {month = g.Key.
Month, year = g.Key. Year, count = g.Count()}.
Pipped to the post.... but this should do the trick. Notice how you can group by multiple fields by using an anonymous type. The properties of the group are available through the Key property of the grouping.
Not sure if this will produce Count(1), though. IIRC it will be Count(*). From c in db.
TblForumAuthors group c by new { c. Join_date. Year, c.
Join_date. Month } into g orderby g. Year, g.
Month select new { Registrations = g.Count(), g.Key. Year, g.Key. Month }.
Thanks! Appreciate it but it doesn't compile 'System.Linq. IGrouping' does not contain a definition for 'Year' and no extension method 'Year' accepting a first argument of type 'System.Linq.
IGrouping' could be found – Tom Gullen Jul 5 at 20:38 As mentioned in other answers, you were missing the Key property. My query should have compiled from the C# compiler in my head.... – MiG Jul 5 at 20:42.
Db. TblForumAuthors . GroupBy(c => new {c.
Join_date. Month, c. Join_date.
Year}) . OrderBy(g => g.Key. Year).
ThenBy(g => g.Key. Month) . Select(g => new { Registrations = g.Count(), Year = g.Key.
Year Month = g.Key. Month }).
I'll bet there are better ways to do it, but here's one. If the table had two fields defined like this: tblForumAuthor ========================== Join_Date date Name nvarchar(50) You could get a report of the number of people joining in each Month+Year combo like this: var db = new DataClasses1DataContext(); var report = from a in db. TblForumAuthors group a by new {Year = a.
Join_Date. Year, Month = a. Join_Date.
Month} into g select new { Year = g.Key. Year, Month = g.Key. Month, Registrations = g.Count() }; foreach( var item in report) { Console.
WriteLine(item. Year + " " + item. Month + " " + item.
Registrations); }.
It is more like this - sorry don't have ability to test it var results = from r in tblForumAuthorm group r by r. Join_date into select new { Year =r. Join_Date.
Year, Month = r. Join_date. Month }.
This is wrong! You are grouping by the whole date including day, hour, second ,... – valipour Jul 5 at 20:42.
And it has Mssql database feature. I want to generate my database on GoDaddy's server to use it online.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.