Click here to Skip to main content
15,892,809 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: LINQ "let" Pin
Richard Deeming8-Jun-16 8:40
mveRichard Deeming8-Jun-16 8:40 
GeneralRe: LINQ "let" Pin
90823658-Jun-16 5:28
90823658-Jun-16 5:28 
GeneralRe: LINQ "let" Pin
Sander Rossel8-Jun-16 5:51
professionalSander Rossel8-Jun-16 5:51 
GeneralRe: LINQ "let" Pin
Nicholas Marty9-Jun-16 2:53
professionalNicholas Marty9-Jun-16 2:53 
GeneralRe: LINQ "let" Pin
Sander Rossel9-Jun-16 3:43
professionalSander Rossel9-Jun-16 3:43 
GeneralRe: LINQ "let" Pin
Nicholas Marty9-Jun-16 4:40
professionalNicholas Marty9-Jun-16 4:40 
GeneralRe: LINQ "let" Pin
James Curran9-Jun-16 4:18
James Curran9-Jun-16 4:18 
GeneralRe: LINQ "let" Pin
Marc Clifton8-Jun-16 7:57
mvaMarc Clifton8-Jun-16 7:57 
OriginalGriff wrote:
I can't get my head round the Linq syntax, so I always use method chaining.


I tend to use both, depending on what I'm doing. For example, this:
var categoryRanks = (from gs in geekSkills
  where (gs.ProfileId == profile.Id)
  join s in skills on gs.SkillId equals s.Id
  select new { Level = gs.Level, CategoryId = s.CategoryId } into gss
  join c in categories on gss.CategoryId equals c.Id
  select new { Level = gss.Level, Name = c.Name } into gssc
  group gssc by new { gssc.Name, gssc.Level } into g
  select new SkillLevelBySkillByCategory() { 
    SkillLevel = g.Key.Level, 
    SkillLevelCount = g.Count(x => x.Level == g.Key.Level), 
    Name = g.Key.Name });

seems more readable to me than method chaining, but I also do things like this:
T record = mappedRecords[typeof(T)].Cast<T>().Where(r => r.Row == row).Single();

because here, it flows better.

Marc

Marc
Imperative to Functional Programming Succinctly

Contributors Wanted for Higher Order Programming Project!

Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

GeneralRe: LINQ "let" Pin
Nish Nishant8-Jun-16 10:02
sitebuilderNish Nishant8-Jun-16 10:02 
GeneralRe: LINQ "let" Pin
Kenneth Haugland8-Jun-16 4:45
mvaKenneth Haugland8-Jun-16 4:45 
GeneralRe: LINQ "let" Pin
Sander Rossel8-Jun-16 5:44
professionalSander Rossel8-Jun-16 5:44 
GeneralRe: LINQ "let" Pin
BillWoodruff8-Jun-16 8:29
professionalBillWoodruff8-Jun-16 8:29 
GeneralRe: LINQ "let" Pin
Richard Deeming8-Jun-16 8:52
mveRichard Deeming8-Jun-16 8:52 
GeneralRe: LINQ "let" Pin
BillWoodruff8-Jun-16 12:46
professionalBillWoodruff8-Jun-16 12:46 
GeneralRe: LINQ "let" Pin
Mark Whybird8-Jun-16 21:24
Mark Whybird8-Jun-16 21:24 
GeneralRe: LINQ "let" Pin
Richard Deeming9-Jun-16 1:38
mveRichard Deeming9-Jun-16 1:38 
GeneralRe: LINQ "let" Pin
Nicholas Marty9-Jun-16 2:54
professionalNicholas Marty9-Jun-16 2:54 
GeneralRe: LINQ "let" Pin
Mark Whybird9-Jun-16 13:41
Mark Whybird9-Jun-16 13:41 
GeneralRe: LINQ "let" Pin
Mark Whybird9-Jun-16 13:40
Mark Whybird9-Jun-16 13:40 
AnswerRe: LINQ "let" Pin
Nish Nishant8-Jun-16 10:01
sitebuilderNish Nishant8-Jun-16 10:01 
GeneralRe: LINQ "let" Pin
Super Lloyd8-Jun-16 14:55
Super Lloyd8-Jun-16 14:55 
GeneralRe: LINQ "let" Pin
louthy9-Jun-16 10:38
louthy9-Jun-16 10:38 
NewsOverdosing on anti-diarrhea drugs: Only in America Pin
Cornelius Henning8-Jun-16 2:57
professionalCornelius Henning8-Jun-16 2:57 
GeneralRe: Overdosing on anti-diarrhea drugs: Only in America Pin
Mike Hankey8-Jun-16 3:04
mveMike Hankey8-Jun-16 3:04 
GeneralRe: Overdosing on anti-diarrhea drugs: Only in America Pin
phil.o8-Jun-16 3:18
professionalphil.o8-Jun-16 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.