Sunday, September 27, 2009

LINQ and Entity Framework Posts for 9/21/2009+

Note: This post is updated weekly or more frequently, depending on the availability of new articles.

Entity Framework and Entity Data Model (EF/EDM)

Nikolaos Kantzelis dives into ASP.NET 4.0,SEO and meta tags in this 9/27/2009 post:

I am thinking to create a new series of posts regarding ASP.NET and SEO (Search Engine Optimisation). I am going to start with this post, talking about some new features that make our apps more SEO friendly. At the end of the day, there is no point having a great application and somehow “scare” the search engines away. This is going to be a short post so let’s quickly have a look at meta keywords and ASP.NET 4.0.

Evolutionary Geek’s Pre-Generating Entity Framework Views with Embedded Metadata post of 9/24/2009 covers this problem and its solution:

Problem: When you are using embedded metadata in your Entity Framework project, the MSDN topic for How to: Pre-Generate Views to Improve Query Performance (Entity Framework) comes up short.

Solution: This posting shows a simple (if tedious) technique for working with both embedded metadata and the pre-generated views.

Alex James continues his Entity Framework Tips series with Tip 36 – How to Construct by Query of 9/23/2009:

While writing my tips series and writing EF controllers for MVC I found that I regularly wanted to create and attach a stub entity.

Unfortunately it isn’t quite that simple, you have to make sure the entity isn’t already attached first, otherwise you’ll see some nasty exceptions. …

And concludes:

Again I’ve demonstrated that mixing EF Metadata and CLR Expressions makes it possible to write really useful helper methods that take a lot of the pain out writing your apps.

Mike O’Brien’s Linq to Entities Query Visualizer post of 9/22/2009 points to Raja Venkatesh’s LINQ to Entities query visualizer download:



Simon Segal’s A Linq To SQL Saga Persister for NServiceBus post of 9/22/2009 posits:

NServiceBus is becoming a very popular Open Source development framework and out of the box it supports some very elegant feature extensibility points (thanks Udi) that have been designed very deliberately in a technology agnostic way. This allows us as developers to write our own implementations of certain features in the technology of our choice, and the subject of this post focuses on extending the Saga Persister. However at this point let me just say that it may well be worth your while to read Udi’s post on Saga’s before continuing and then come back here to finish.

Eric J. Smith and Shannon Davidson explain in LINQ to SQL - Detach Entities how to “Easily detach entities when using LINQ to SQL”:

How do I use disconnected entities with LINQ to SQL? Every developer that has used LINQ to SQL has asked this question in dismay. Where is the detach? How do I use these entities with services, JSON, encapsulation, and multiple data contexts? All are normal questions when building a solid framework. By default, LINQ to SQL does not like to let go of its entities and does not see a reason that an entity should be disconnected from its context. PLINQO makes it very simple to detach LINQ to SQL entities. We are going to walk you through how this was implemented in PLINQO by showing how to manually add the detach functionality using LINQ to SQL.

Joydip Kanjilal confuses LINQ to SQL with LINQ to Objects in his Guidelines and Best Practices in Optimizing LINQ Performance article for ASP.NET Pro magazine’s September 2009 issue:

Language Integrated Query (LINQ) is a query execution pipeline for use in the managed environment of .NET Framework. In essence, LINQ is Microsoft's object relational mapper between your business objects and the underlying data sources and provides a simplified framework for accessing relational data in an object-oriented fashion.

Although LINQ is great in the sense that you can query data in your object model seamlessly, there are certain factors that you need to consider to ensure that your application performs to the extent you need it to. This article takes a look at some of the best practices that you can follow for enhancing the performance of LINQ in your applications.

LINQ to Objects, LINQ to XML, et al.

DevExpert explains Implementing a LINQ version of SQL’s LIKE Operator in this 9/25/2009 post:

One of the requirements of one of my recent projects was to implement a search page which allowed the user to enter a search term that supported wildcards.  The search term could contain any number of wildcards in any position within that term.

If you’ve done anything like this before, you probably know there’s nothing built-in to LINQ that supports this type of behavior.  Sure, you could use a combination of String.StartsWith, String.EndsWith, or String.Contains, but this could quickly become too cumbersome if there are many wildcards and/or they are scattered throughout the search term. …

Damien Guard’s When an object-relational mapper is too much, DataReader too little post of 9/22/2009 begins:

I fired up Visual Studio this evening to write a proof-of-concept app and found myself wanting strongly typed domain objects from a database but without the overhead of an object-relational mapper  (the application is read-only).

One solution is to write methods by hand, another is to code generate them but it would be nice to be able to do:

var customers = new SqlCommand("SELECT ID, Name FROM Customer", connection)
  .As(r => new Customer { CustomerID = r.GetInt32(0), Name = r.GetString(1) }).ToList();

So for any DbCommand object you can turn it into a bunch of classes by specifying the new pattern.

Damien then shows you the tiny helper class for “the new pattern.”

Beth Massi explains Mail Merging Into a Single Word Document Using XML Literals in this 9/23/2009 post:

With the release of Microsoft Office 2007 we can work with a much simpler, standard, XML format called Open XML which opens the door for many types of applications that cannot work via COM. What if you needed to build a scalable web service that processes many documents in high volume? What if you wanted to quickly read or write to these formats from a client application but wanted to have minimal dependencies on other applications? These types of programs do not want to require Microsoft Office be installed to run. The cool thing is you have the tools already with Visual Basic 2008. XML Literals are an easy way to manipulate any kind of XML, including Open XML.

She continues with Merging Text & Photos into a Word Document using Open XML SDK of 9/24/2009:

Yesterday I posted about how we could create a letter generator (mail merge) that took data from a database to create a Word 2007 document using the System.IO.Packaging class. I showed how to take data from Northwind using a single LINQ query to create XDocument objects representing letters to customers and then create a single document of all the data using XML Literals.

Today I want to show how we can embed images into the documents as well as text. Since we’re using Northwind for this example, we’ll use the Employee.Photo field from that database.

ADO.NET Data Services (Astoria)

No new articles of significance this week.

ASP.NET Dynamic Data (DD)

Chris Swain’s Distracted by Dynamic Data post of 8/4/2009, which I missed at the time, begins:

Lately my work has kept me so busy I haven't had time to do much with Tank Wars and Silverlight in general.  However, my work project is out on the fringe of Microsoft's latest technology using ASP.NET Dynamic Data.  There are lot's of posts out there on the basics of this new approach at data driven web site development, so I won't bother to cover them.  If you need a place to start, check out the Dynamic Data site. 

While this is a nice new tool to help us rapidly create data driven web sites, it is still a relatively new tool.  As such, it has some bugs and oversights that have yet to be addressed.  I wanted to cover a couple of these in this post.

blog comments powered by Disqus