Galin Iliev's blog

Software Architecture & Development

Entity Framework for DBAs

There is a lot of noise these days around Visual Studio 2008 and fancy LINQ to SQL and Entity Framework and discussions how they will change the way data driven applications is done.

But somethign was missed 'till now - How this would affect database administrators (DBAs)?  Erick Thompson post a good explanation about these technologies that targets DBA and explain what will be changed on their daily job.

Go and read ADO.NET Blog post - it worths.

Ultimate C# Tutorial

Unified C# 3.0 Specification Now Available. In this document (above 500 printed pages) you can find every C# feature and some examples. It can be called also "Ultimate C# Tutorial".

This document combines the 1.1 version of the spec, the 2.0 version, and various other bits and pieces into one large document some 500 pages in length. Here you will find the definitive technical description of the C# language in the words of the engineers who created it.  It is the single most authoritative reference for the C# language. Though not called out by name in this document, many of the people who created the C# language contributed to it, and they are its primary authors.

(via Charlie Calvert's Community Blog )

Update: If you are non-Bulgarian speaker or you do not want to read my LINQ Tutorial and you want quickly to ramp up with C# 3.0 (without reading 519 pages) you can find read C# 3.0 specifications (30 pages) by Anders Hejlsberg
(thanks to Matthieu Mezil)

LINQPad and Think in LINQ

I've just found that Joe Albahari, co-author of the forthcoming C# 3.0 in a Nutshell, has released the Beta 2 version of his beta LINQPad - it is like Notepad for LINQ :)

There is also a challenge:

  1. Locate the shortcut for SQL Management Studio on your Start Menu and move it some place else.
  2. In its place, insert a shortcut to LINQPad.
  3. For the next week, perform all your ad-hoc SQL queries using only LINQPad.

At the end of the week, you will actually think in LINQ, rather than thinking in SQL and translating to LINQ. (LINQPad also allows old-fashioned SQL queries for tasks are genuinely impossible or clumsy in LINQ. You'll feel an unpleasant sense of failure, though, should you cheat and use this feature frivolously :)

If you can write all your ad-hoc queries in LINQ, you have a big head-start over everyone else in C# 3.0, LINQ and LINQ to SQL. (Further, LINQPad gives you a knowledge of LINQ that does not depend on Intellisense, and so will not fall to pieces at job interviews!) And continued use of LINQPad will keep your LINQ knowledge alive—if you're not lucky enough to be using LINQ in your current projects.


LINQ Tutorial - it is on final curve

Last week I was able to finish the biggest branch of LINQ Tutorial - LINQ to SQL, and most common LINQ to Objects. I have raw version of LINQ to Entities and LINQ to DataSet and I need a couple days to finish them.

So I am on final curve - I have to wrap up LINQ to XML and it's subset LINQ to XSD - My hopes are to finish it 'till the end of the week.

Indexed LINQ

With the upcoming Visual Studio 2008 and new C# and VB syntax the abbreviature LINQ is already wide spread. With LINQ are mentioned a few branches- LINQ to SQL (the most popular one), LINQ to Objects, LINQ to XML.

But adding features for working with data to object oriented language brings its questions. Let's see the definition of LINQ to Objects from

"LINQ to Objects allows .NET developers to write “queries” over collections of objects. Out of the box there is a large set of query operators that provide a similar depth of functionality to what we expect from any SQL language working with a relational database, and if what we need isn’t present out-of-the-box, we can add our own."

Sounds good, isn't it? But the question arises: By having collection of objects (similar to tables) and language that allow writing queries (similar to SQL) is is there a way to speed up processing (similar to indexes)?

This is reasonable question and there are articles on the subject already. This is called i4o (indexes 4 objects). Here are some articles and links:

I think this is interesting and there is a future for it but in low market segment. I know there is such thing as Object Database and this sounds like one. In the posts I read it seems that MS won't put effort on something that would compete SQL Server 2005 Express if it grows enough. They'll rather improve SQL Server to support mapping and with this they'll achieve part if the goal while having SQL Server in the shape we know it. This is not in far future. It is already known that MS SQL Server 2008 will have Entity Framework built in.



LINQ 2.0

Erik Meijer, the "Creator of LINQ", summarizes in his paper "LINQ 2.0: Democratizing the Cloud"  what is achieved with LINQ 1.0 ( it is on Beta 2 stage and architecture&design stage is passed so we know what is in it ) and what are the goals for LINQ 2.0.

This is intersting reading as this is first place I met LINQ written with a version number :) and this can give an idea on what is coming next :)

Andres Aguiar gives explanation of "Democratizing the Cloud":

Democratizing the cloud means “Make easier to program distributed applications”. He wants us to build a single tier app and publish it in multiple tiers.

This is not all... there is a bit more: there is a video on Channel9 Erik Meijer: Volta - Wrapping the Cloud with .NET - Part 1.

I am not sure if LINQ 2.0 and MS Codename Volta are related, though... Mary Jo Foley writes:

* Volta is an academic incubation project focused on programming in the cloud, Ajenstat said. Volta has no connection to Astoria, Jasper or Katmai. Instead, it is focused on how you expose the Web Services and SOA data that is in the cloud, he said. Volta isn't about programming against hosted SQL Server; it's more futuristic than that. 

But wait.. There is another unknown word ( at least use of this word ) - Cloud. Again Mary Jo Foley tries to give answer in hist post Is Microsoft’s Cloud OS actually a Cloud DB?

The bad news and the good news

LINQ to SQL Debug Visualizer was removed from VS 2008 Beta 1... if you use LINQ to SQL you know how useful it is to examine generated SQL code from LINQ statements as well as returned results. but it was removed from Beta 1 and still missing in Beta 2...

Now the good news :) There is way to install it back. But this is not all. You can download the source code and make changes (if you want) or just examine it. I guess there are no doubts who posted it :) - Scott Guthrie wrote a post with full explanation what is LINQ to SQL Debug Visualizer, how to use and how to install.

How to build custom LINQ provider?

Many people asked this question since May 2006 LINQ Preview was announced. We know there are several providers implemented by Microsoft:

But if we have custom datastore how we can implement LINQ provider for it? For a long time LINQ to Amazon by Fabrice Marguerie, was the only third-party provider and although he explained it was still many question left opened. (I've just found that there was LINQ to WebQueries by Hartmut Maennel predates LINQ to Amazon by few days.)

Matt Warren started very nice and deep series of blog posts that covers the process of writing custom LINQ provider. Even if you don't plan to write custom provider this post can give you an idea how the things work:

Of course, it is good idea to check if the provider is not written already :) See below list of providers.

OakLeaf Systems blog has a nice post that gives list of third-party LINQ providers (re-posted): 

  • LINQ to WebQueries by Hartmut Maennel handles searches in the SiteSeer and MSDN Web sites. (This provider predates Fabrice's LINQ to Amazon provider by a few days.)
  • LINQ to Amazon by Fabrice Marguerie, a co-author of the forthcoming LINQ in Action book, was the first third-party LINQ provider that I know of. LINQ to Amazon returns lists of books meeting specific criteria.
  • LINQ to RDF Files by Hartmut Maennel handles queries against Resource Description Format files' triples. Part I of the two-part post is here.
  • LINQ to MySQL by George Moudry, based on the LINQ May 2006 CTP, was in the development stage as of January 2007, but George says it's "capable of simplest queries and updates" and "now has support for most primitive joins."
  • LINQ to NHibernate by Ayende Rahien (a.k.a. Oren Eini) translates LINQ queries to NHibernate Criteria Queries and is based on the Orcas March 2007 CTP. The documentation that describes development of the provider presently is at the Part 1 stage.
  • LINQ to LDAP by Bart de Smet is a "query provider for LINQ that's capable of talking to Active Directory (and other LDAP data sources potentially) over LDAP." As of 4/11/2007, Bart's "IQueryable Tales - LINQ to LDAP" consisted of Part 0: Introduction, Part 1: Key Concepts, Part 2: Getting Started with IQueryable, Part 3: Why do we need entities?, Part 4: Parsing and executing queries, and Part 5: Supporting Updates.
  • LINQ to Flickr by Mohammed Hossam El-Din (Bashmohandes) uses the open-source FlickrNet C# library as its infrastructure.
  • LINQ to Google Desktop by Costa Rican programming language enthusiast Luis Diego Fallas supports GDFileResult and GDEmail types. A subsequent Adding support for projections to Linq to Google Desktop implements the LINQ Select expression.
  • LINQ to SharePoint by Bart de Smet supports writing LINQ queries for SharePoint lists in both C# 3.0 and Visual Basic 9.0 and communicates with SharePoint via Web services or though the SharePoint Object Model. The SpMetal command-line utility automates C# or VB class generation.
  • LINQ to Streams (SLinq, Streaming LINQ) by Oren Novotny processes continuous data streams, such as stock tickers or sensor data. The project's home page on CodePlex includes an animated GIF simulation of a stock ticker displayed in a DataGridView. The current version supports Select, Where, Order By, and Descending only.
  • LINQ to Expressions (MetaLinq) by Aaron Erickson (the developer of Indexes for Objects a.k.a i4o*) lets you query over and edit expression trees with LINQ. Like .NET strings, LINQ expression trees are immutable; the only way you can change a LINQ expression tree is to make a copy, modify the copy, and then replace the original. MetaLinq's ExpressionBuilder lets you create an "Editable Shadow of an expression tree, modify it in place, and then by calling ToExpression on the shadow tree, generate a new, normal, immutable tree." ExpressionBuilder is an analog of the .NET StringBuilder.

* i4o isn't a LINQ provider, per se, but a helper class that can increase the speed of LINQ queries against large collections by a factor of 1,000 or more. InfoQ published on June 22, 2007, Aaron Erickson on LINQ and i4o, an interview of Aaron Erickson by Jonathan Allen about i4o's purpose and background.

Hope you'll find this useful