Some linq love
Well, because of things like this:
var entityModels = model .Sessions .First() .Views .OfType<SessionEntities>() .Single() .EntityModels;
I feel like I am working with XPath or CSS selectors :-)
Well, because of things like this:
var entityModels = model .Sessions .First() .Views .OfType<SessionEntities>() .Single() .EntityModels;
I feel like I am working with XPath or CSS selectors :-)
And 4 more posts are pending...
There are posts all the way to Feb 17, 2025
Comments
mmh. You're saying that like it's a good thing ;)
Is this love, baby, or is it, uh-huh, Just, uh, confusion?
Where's linq?
That's all Linq - the pseudo-sql is syntactic sugar. (tongue twister)
Looks like a good thing - type safe, self-asserting expectations, terse, and readable. Or was this an example of trying to do too much at once? Seems the comparison to XPath or CSS could be taken either way...
It must be a test, to see if we actually read what he blogs.
7 lines of sin ihmo.
@blatent-villagers-with-forks-and-firey-sticks
I'm not using linq, and infact I'm telling everyone it sucks because its black magic, how dare something come along and blow away the crap I've spent years trying to bring to life fruitlessly..
Oh wait sorry I'm not at all bitter about new technologies.
This isn't Linq. Linq - language integrated query - is the integration of the query syntax into the language. I.e. Linq is not a series of methods (even extension methods) but the actual syntax difference.
That said, I don't like this code because the first thought was 'Hmm, what does it do?' - and the second thought was the same.
@configurator I think I'll need to respectfully disagree... While the native language syntax is one aspect of LINQ, the term itself applies to the overall capability.
msdn.microsoft.com/.../aa904594.aspx
"LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities."
en.wikipedia.org/wiki/Language_Integrated_Query
"Query syntax: Languages are free to choose a query syntax, which it will recognize natively. These language keywords must be translated by the compiler to appropriate LINQ method calls."
I do this sort of thing all of the time but I always feel the ghost of Demeter staring holes in my back when I do. It's also a PITA to debug so most projects I use this sort of thing on end up with a
public static T Expose <t(this T target, Action <t action)
{
action(target);
return target;
}
That way you can
var entityModels = model
<sessionentities()
It's messy and not something I recommend
Comment preview