LINQ in Action roller

September 2006 - Posts

  • Notes on Implementing the Visitor Pattern using Extension Methods

    Well, I've checked with one of the experts, Dr. Ralf Lämmel , and he confirmed: as soon as you use a StringBuilder, it's not pure. So example 4 in LINQ to XML: Implementing the Visitor Pattern using Extension Methods can't be said to be pure. However, I think that in terms of analysis of queries with an eye to determining if they could be executed in separate threads in PLINQ, using the StringBuilder like this would work. Also, Ralf made a good point about using the Aggregate standard query operator: Read More...
  • LINQ to XML: Implementing the Visitor Pattern using Extension Methods

    We often use the Visitor pattern to separate the structure of an object tree or collection from the operations performed on that tree or collection. There are lots of ways in LINQ where you can visit some function on a collection, but when implementing this pattern as a couple of extension methods in LINQ to XML, we can pass the element depth as an argument to the delegate. This allows us to do interesting things because we know the element depth. For instance, we can use the Visit method to transform Read More...
  • Expressions Invoking Other Expressions

    Hi all, I've been playing with the LINQ May CTP. I'm particularly interested in the expression tree stuff. It looks really great, but there is one aspect that is not quite working the way I had hoped. I'm posting to see if I'm missing something or if this is likely to be addressed in the future. Ok, so I can write a lambda expression like this: Func add5 = x => x + 5; And then I can write another lambda expression that uses that one: Func add5AndDouble = x => add5(x) * 2; This all works great. Now Read More...
  • Audit Trail with Linq and db.SubmitChanges()

    Hi I would like to create a Audit Trail entity in my database. The idea to keep a track of all the inserts, updates and deletes in tables. This table will have columns like Tablename, fieldname, recordid, beforevalue, aftervalue, datechanged, changedby, action(insert,update,delete). I would like this to happen as db.submitchanges is called. Can anyone help me how to get this one working. Pardon me if I am not clear on my requirement. Please ask any question for clarifications. Thanks Anubhav Read More...
  • Working with an XMLDocument(LINQ)

    Hello, I want to work on an XMLDocument using LINQ. Let me to explain the scenario briefly. I have an XML file like that: some value some value some value some value now, first I want to select a specific city such that Sivas with a variable name _cityName and then for each date value nested by the city will return a City Object initiated with the values of _cityName, all and elements values. My City class' constructor is something like that: public City (string _cityName, MyTime[] _timeVals) and Read More...
  • Fun with Anonymous Types and LINQ to XML

    You can, of course, use C# anonymous types to create types that are more than simple tuples. For example, you can nest anonymous types to create an object graph: var PurchaseOrder = new { PurchaseOrderNumber = "99503", OrderDate = DateTime.Parse("1999-10-20"), Addresses = new [] { new { AddressType = "Shipping", Name = "Alice Smith", Street = "123 Maple Street", City = "Mill Valley", State = "CA", Zip = "90952", Country = "USA" }, new { AddressType = "Billing", Name = "Robert Smith", Street = "8 Read More...
  • More Notes on LINQ to Text Files

    Following are a few additional notes regarding the Linq to Text Files example. Taking Advantage of Multiple CPUs If you have some type of computing where you need to process large text files, and the processing of the text files is processor intensive, the possibility exists in the future where you could factor your processing into separate LINQ queries and perhaps a future version of LINQ could parcel out each query to a separate CPU. You could take advantage of parallel processors without extensive Read More...
  • Earth Renamed 'Hades'

    Apparently Xena was not the only solar body renamed this week by the International Astronomical Union. In an attempt to align all planet and dwarf planet names along the Greek pantheon theme, a group of rather overzealous and somewhat tipsy astronomers packed into the conference's overflow area within the hotel's cocktail lounge agreed unaminously last night that yet another solar body should be renamed, reclassified, and remarketted. You see, all those silly star-gazers thousands of years ago, too Read More...
  • PLinq Me!

    Sounds cool ! One of the most exciting things about Linq is the ability for alternate implementations to be created for processing Linq expression trees. Microsoft is working on a parallel implementation of its Language Integrated Query technology that will help programs execute faster, said the creator of the LINQ technology. Anders Hejlsberg, a Microsoft technical fellow and lead architect for the C# language, said Microsoft has an internal project known as PLinq, which is an effort to create a Read More...
  • XML Notepad 2006

    XML Notepad 2006 provides a simple intuitive User Interface for browsing and editing XML documents. XML Notepad shows how to use some advanced features of System.XML in the .NET Frameworks 2.0. The download includes source code. See the handy design doc that goes with it. Features include: Tree View synchronized with Node Text View for quick editing of node names and values. Incremental search (Ctrl+I) in both tree and text views, so as you type it navigates to matching nodes. Cut/copy/paste with Read More...
  • Linq to XML needs an XNamespaceScope class

    When working with XML data we inevitably have to concern ourselves with XML namespaces + XML namespace prefixes. The Linq to XML API has been designed to make dealing with namespaces and namespaces prefixes as direct and straightforward as possible. Rather than having to deal with XmlNamespaceManagers and the like we simple reference all of our elements and attributes using their fully expanded name (namespace + local name). While the simplification provided by Linq to XML makes dealing with namespaces Read More...

Featured Item

This Blog

Sponsoring

Syndication