Shawn

Shawn Wildermuth

Stories

Tagged with LINQ


ADO.NET Data Services 1.5 Feature: Projections

SilverlightIf you've been following my blog, you should know that I am keeping a pretty close watch on ADO.NET Data Services. The team recently released a second CTP of the new version with some interesting features. This CTP has some pretty compelling additions, but I am going ot focus on one in particular.

I've been teaching and using ADO.NET Data Services for a long time and I like showing off exposing a LINQ-based provider (Entity Framework, NHibernate or others) to a Silverlight application. While ADO.NET Data Services does expose its API through a REST API, the magic for me is in its use in Silverlight. In case you haven't been following along, using the Silverlight client you can issue a LINQ query through the Silverlight client (though in fairness, the full power of LINQ is not supported in the client):

var qry = (from g in ctx.Games
           where g.Genre.Name == "Shooter"
           orderby g.ReleaseDate
           select g) as DataServiceQuery<Game>;

qry.BeginExecute(new AsyncCallback(r =>
{
  try
  {
    theList.ItemsSource = qry.EndExecute(r).ToList();
  }
  catch (Exception ex)
  {
    // NOOP
  }
}), null);

This is a powerful feature so that (unlike web services) developers can use a looser service definition to define their data stack. Let the developer who needs data be able to sort, filter and shape that data as necessary.

Read...


Using LinqPad and Entity Framework Models

Url: http://www.simonsegal.net/blog/2009/01/20/linqp...

Pardon the link post, but this is a great short walk-through of using LinqPad to execute EF queries against your own model. Great for testing query ideas against your data.  Highly recommended.

One note is that while the AutoCompletion extension of LinqPad is great, it not necessary for this technique to work.  Please buy AutoCompletion to support the great work in LinqPad, but it isn't necessary to get it to work.

Read...


Caution when Eager Loading in the Entity Framework

Url: http://code.msdn.microsoft.com/EFExtensions

UPDATE: Roger Jennings correctly stated, I meant to say that Include is *not* a guarantee.

When I am using the Entity Framework for a project, I have gotten into the habit of using eager loading via the Include syntax. In case you're not familiar it, the Entity Framework has a different philosophy than other data layers (e.g. NHibernate). In the Entity Framework, relationships have to be manually loaded when they are lazy loaded (so developers never have network round-trips without explicitly knowing about it). Whether you agree or not with this philosophy, understanding how it works is helpful when you're working with the Entity Framework.

Read...


Update on NHibernate 2.0 and LINQ

Url: http://ayende.com/Blog/archive/2008/09/11/NHibe...

It seems that because of some internal NHibernate changes that are required to make NHibernate LINQ work really well, the current version of NHibernate LINQ will not be supported.  Evidently there are a number of complex queries that do not work correctly under the current codebase. Its been announced that these changes will be made in the NHibernate 2.1 (which is in development). Follow the link to read the full details!

Read...


Book Review: LINQ in Action

Url: http://www.amazon.com/LINQ-Action-Fabrice-Margu...

I've spent much of the last couple of weeks trying to strengthen my LINQ knowledge. A friend of mine is one of the authors of a LINQ book so I figured it was a good match to dig deeper.

The book covers a lot of topics that emcompass LINQ including LINQ basics, but also LINQ to SQL, LINQ to XML. I like that it starts out with a discussion of the problem and doesn't dive directly into the solution. In addition, I think it teaches the technology without resorting to starting with database applications as the example. Anyone who has heard me talk about LINQ knows that I can't stand that LINQ to SQL is the wrong way to teach it to new people...they didn't fall into that trap.

Read...


Implementing IUpdatable (Part 3)

UPDATE: I know the title is wrong and it should be IUpdateable but I didn't want to break any links for any RSS feeds that already had it.

If you haven't read Part 1 or Part 2 first, you should start there.

In this final part of the IUpdateable implementation, we will discuss the rest of the methods which includes ClearChanges, ResolveResource, ReplaceResource, SetReference, AddReferenceToCollectionRemoveReferenceFromCollection and SaveChanges.

Read...


Speaking at the Atlanta .NET Users Group

Url: http://www.atlantadotnet.org

Next Monday night (July 28th, 2008), i'll be giving the short Q&A session at the Atlanta .NET Users Group.  The topic?  NHibernate's LINQ and ADO.NET Data Services support.  If you're interested in using NHibernate but don't want to give up your LINQ skills, stop by for a listen!

Read...


NHibernate.LINQ with ADO.NET Data Services

Silverlight Logo

Now that my ADO.NET Data Services support has been merged into the trunk of NHibernate.LINQ, I do have some caveats about using NHibernate.LINQ with ADO.NET Data Services.  ADO.NET Data Services is a beta 1 product so there are some bugs and issues that you will either need to avoid or work around.

The biggest issue is around entity identity. ADO.NET Data Services must know how identity is established for objects in order to support the Data Service. It does this in a two step process:

Read...


Wildermuth.com By Example - Part 1

In response to some requests that I have received, I decided to write a several part blog on some of the techniques I used in developing Wildermuth.com. In this first example, I am going to discuss the use of LINQ and data in my site. 

In moving from www.adoguy.com to www.wildermuth.com, one of my goals was to use LINQ as much as possible to see the travails of using it on a real project. I have done a lot of small samples with LINQ but did it hold up for real work?  Suffice to say I am pretty impressed (though whether a blog is 'real work' is up for discussion, but its a better exercise of the technology than my samples had been).

When I say LINQ, I want to be specific.  LINQ to me really is "Language Integrated Query".  The data store behind is a secondary discussion and whether the Entity Framework, LLBLGen Pro, or nHibernate, I really wanted to make sure that the way I queried data in the C# code was LINQ. I was hoping to avoid dropping down into SQL as much as possible.

Read...


Jim Wooley's ThinqLinq is now Open!

Url: http://www.thinqlinq.com

Jim Wooley has a live LINQ-based blog site that Jim Wooley's been working on with every version of LINQ it seems like forever. If you have a chance to stop by or see what he's been Thinqing of, i'd suggest stopping by.

Read...


Reversing My Opinion of LINQ

Most of my exposure to LINQ has been in very short snippets and sessions at various conferences and blogs. My initial reaction was fairly negative. This negative reaction was based on several key factors:

Let me discuss these points individually.  I think that LINQ for SQL is not a compelling ORM (and is mostly useful only in the RAD or prototyping of applications, much like Typed DataSets are now). The more problematic part of this factor is that it only confuses developers as LINQ is not about database development but about integrating query into code. Integrating a query mechanism into the language is a great feature that should be explained but using LINQ for SQL as a demonstration tends to lend the comparison with nHibernate, LLBGenPro, Typed DataSets and such.  The reality is that LINQ for SQL is an interesting implementation of LINQ but clouds the issue.

As for equating LINQ as having a SQL-like syntax, there are three specific problems with this in my mind:

Read...