damirarh / damirscorner-utterances

utteranc.es comments for https://damirscorner.com
0 stars 0 forks source link

/blog/posts/20181207-NoSupportForTuplesInExpressionTrees.html #79

Open damirarh opened 1 year ago

damirarh commented 1 year ago

Imported

URL: https://www.damirscorner.com/blog/posts/20181207-NoSupportForTuplesInExpressionTrees.html

damirarh commented 1 year ago

Imported comment written by jjxtra on 2019-10-28T23:12:04

Thanks so much for sharing, I appreciate it!

damirarh commented 1 year ago

Imported comment written by Emil Wall on 2020-03-13T11:01:14

Be aware that this will materialize data for all matching persons although only the first is actually returned from the method. Probably a good idea to do something like this instead, assuming there will always be at least one match:

var match = ctx.Persons
.Where(person => person.Id == id)
.Select(person => new { person.Name, person.Surname })
.First();

return (match.Name, match.Surname);

damirarh commented 1 year ago

Imported comment written by Поллитрук on 2021-06-29T13:51:51

`AsEnumerable` is more preferable to avoid buffering of entire result set into memory.

var match = ctx.Persons
.Where(person => person.Id == id)
.Select(person => new { person.Name, person.Surname })
.AsEnumerable()
.Select(person => (person.Name, person.Surname))
.First();