c# - Lambda Query GroupBy with boolean values -


I have many examples where I need to return a data list which is .GroupBy Uses. Apart from dates and integers, I also need to return the boolean values, which I do not like. An example model:

  Public Sector HoldelCank list {Public DateTime StartDate {Received; Set; } Public Date Expired {Received; Set; } Public Intranet {Received; Set; } Public bool startTime {get; Set; } Public Bull Endime {Received; Set; }}  

Below is the controller because it is currently:

  var model = _db.AnnualLeaves. Where (R => R. startdate and lieutenant; = Tte & amp; Randडेट & gt; = TTS) .GroupBy (R => RK Bukade) Select (M = & gt; New Holiday Cache List {startdate = m.max (r = & gt; R. StartDate), Endadet = M. Max (R => R & D), Staff ID = Mminin = & Gt; R.StepferID}}); See Return (model.ToList ());  

What this is what I want, except startdate and endDate I end up with starttime and Time is required to return, which are boolean values, to see I do not know that I need a composite operator, which I do not know about, let me in .GroupBy Required to be included or maybe a nested query is required. There is no doubt that it will be much easier.

I considered changing the data type to an integer, but would like to know if there is a way to "fix" it.

On one side, is there a resource or document to learn Lambda questions? I can get basic information but there is nothing that explains how .GroupBy works, or what are total operators

If you are certain that all startTime and end time values ​​will be the same (or you do not care), You can use . Values:

  var model = _db.AnnualLeaves  for the first item in  group  startTime  and < Where (R => R. startdate and LT; = TTE & R & amp; & amp; & amp; gt; & gt; = TTS) .GroupBy (r = & gt; R. Buched). Select (M => New HolidaysCanc List {startdate = m.max (r = & gt; R.Startdett), Endadet = M.Max (R => Raidate), StafferId = m.in (r = & Gt; r.StafferId, startTime = m.Select (r = & gt; R. starttime). First (), endtime = mi select (r = & gt; rt time) first ()});  

A good resource for lambdass is the article on MSDN.

Looks like a good review of various overall tasks available in LINQ. Unfortunately examples are in VB.NET.


Comments