Welcome to Manicprogrammer Sign in | Join | Help

Browse by Tags

All Tags » Tech » Linq   (RSS)

Linq OfType<T> expression

I just discovered a function in Linq that will save me a bit of typing and allow me to better express myself. For a long while, I've written this: ColorWrapper x = combo.Items.Where( obj => obj is ColorWrapper ).Cast< ColorWrapper >().FirstOrDefault(cw
Posted by willeke | 0 Comments
Filed under: , ,

Linq to SQL usage of XML

Just a reminder of something that has bitten us more than once. If you need to copy an XML value from one data object to another, use this syntax: if ( copiedPlacement != null ) { currentPlacement.FormatXML = new XElement (copiedPlacement.FormatXML);
Posted by willeke | 0 Comments
Filed under: , , ,

Dangers of LINQ

We love LINQ! We have used it for a lot of things on our project, and it has helped us with hitting a lot of deadlines. Unfortunately, in one instance it's been burning us for a few months now, and we didn't know it. Look at the code sample below. I've
Posted by willeke | 11 Comments
Filed under: , , ,

Linq entities and calling Attach()

Back to tech, for now. I like Linq to SQL. A LOT. However, there have been a handful of things that have annoyed me, and one of them is the story around serialization and disconnected entities. They've built a nice engine for it (DataContract-based),
Posted by willeke | 0 Comments
Filed under: ,

Linq to XML follow up - how the magic works

If you're curious how the XNamespace works, just do a "Go to Definition" in VS and you'll see the declarations, the key aspects are: public static bool operator !=(XNamespace left, XNamespace right); public static XName operator +(XNamespace ns, string
Posted by willeke | 0 Comments
Filed under: ,

More LINQ (to XML) happiness

Namespace handling is much improved! Yay for easy namespaces! Anybody who has worked with XML in .NET 1.x or 2.0 knows how much of a pain XML namespaces can be in extracting data, yet they fill a very important part of the XML technology. Now, for linq.
Posted by willeke | 0 Comments
Filed under: , ,

Linq is GREATNESS!

Freaking amazing. Scenario: I need to load the contents of a table into a dictionary of objects keyed by one of the fields. Before: Write the ORM code to load the entire table. (3 lines) Initialize the dictionary (1 line). Write the for each loop to move
Posted by willeke | 1 Comments
Filed under: ,