Galin Iliev's blog

Software Architecture & Development

...and it keeps growing...

This week I spent some of these geek nights... you know - nothing romantic - you in front of PC and filled with passion about technologies :) and I was able to wrap up two of the parts of my LINQ Tutorial (in Bulgarian) - LINQ in details and Basic operators in LINQ.

I will be glad to hear your opinion...

I will try to describe LINQ to SQL 'till the end of the month and with this part most of the tutorial will be finished. Let's see how things will go after long waiting (and hopefully deserved) vacation.

Visual Studio 2008 Beta 2, .NET FX 3.5 Beta 2, and Silverlight 1.0 RC

Well, well... The long waiting is over - Visual Studio 2008 Beta 2 is here (actually here :) )

You can download .NET 3.5  Redistributable too. Also Silverlight has its Release Candidate and it will be available for dowload in next day or two. 

It seems there is some trick with policy so remember:

After the Beta 2 installation has finished, you should run this script to ensure that the installation of .NET Framework 3.5 Beta 2 will not affect the development of ASP.NET AJAX 1.0 applications

Update: I am now installing Beta2 but these are new features for Web Development summarized on ScottGu blog:

VS 2008 Multi-Targeting Support

  • VS 2008 Web Designer and CSS Support
  • VS 2008 Nested Master Page Support
  • VS 2008 JavaScript Intellisense
  • VS 2008 JavaScript Debugging
  • If you have ever installed a previous version of "Orcas" or VS 2008 on your machine (either Beta1 or one of the CTP versions), you need to reset your VS 2008 settings after installing Beta2.  If you don't do this, you'll have an odd set of settings configured (some windows will be in the wrong place), and you'll potentially see some IDE performance slowness.  You can reset your settings by typing "DevEnv /resetsettings" on the command-line against the VS 2008 version of the IDE.

    Orcas June CTP - new features

    I've found interesting blog post about changes in Orcas July CTP at system.data.objects dev guy. Here are they (copied directly):


    • IPOCO -- there's a lot more coming here to bring us closer to true POCO, but this is the first step in that direction and makes the key change to allow the creation of Entity classes that do not inherit from our base class.
    • ObjectContext.Detach() -- will detach an object from the ObjectStateManager associated with an object context so that it can be attached to some other context or reclaimed by the garbage collector
    • Multiple entity sets per type -- this is relatively esoteric, but it does exactly what its name says.  You can define a model which has more than one entity set with the same base type.  This is important because it enables models which work more naturally with various database models.  If you have two tables with the same schema (say "accounts" and "expired_accounts" or something), then you can define entitysets for each of them which use the same entity type rather than needing to create a different entity type which just happens to have all the same properties.  This resulted in a change to a number of the object context APIs -- strongly typed contexts, for instance, now have AddToEntitySetName methods (where EntitySetName is the actual name of each entity set).
    • Support for referential integrity constraints -- This allows you to define a key to one entity type which is made up, in part, of properties which are also in the key of another entity type.  The modeling scenario in the database is where a column is both a foreign key and part of a primary key.
    • Span -- this makes it possible to specify that a query not only return an entity but return some set of related entities in a single round trip and automatically hook-up the graph.  So, for instance, you could say that your customer query should also return the orders for each customer in a single round trip.  We also have an automatic query re-write feature for the object layer that enables a feature we call Relationship Span where queries that retrieve entities will under-the-covers also return relationship information if the relationship is an EntityReference (rather than a collection).  This is usually a quick operation since typically this relationship information is co-located in the relational database as a foreign key property, and it has the very useful property that for many cases entity graphs will automatically be hooked up as long as the relevant entities on either side of the relationship have been loaded.  So, for example, if I query for a set of customers and then I separately do a query for a bunch of orders--any of those orders that are related to those customers will automatically bring along the relationship info and connect the orders up to the customers they go with.
    • Transactions -- specifically integration with System.Transactions.
    • Serialization -- that is, entities are automatically generated with attributes that enable binary serialization.  Unfortunately EntityKeys do not yet serialize but that will be coming in a future CTP.
    • No more default constructors in code-generated classes -- I've already written about this in an earlier blog post.
    • Improvements to stored procedure support -- honestly I can't remember the details of this one just now, and since I'm sitting in the Denver airport where I have limited battery life on my laptop I'll delay looking it up for you.  If anyone is wondering, drop me a note and I'll get back to you.
    • Access to the underlying store connection -- You can now easily access the store connection from an EntityConnection which makes it much easier to go around the covers if you need to.  (But I must say I don't have to do that nearly so often now as I used to -- this framework is actually starting to work pretty well for writing apps, IMHO <grin>.)
    • Directory macros -- Makes it easier to specify where the metadata lives in hosted scenarios
    • Native SQL read-only views -- You've got to see one of the demos Tim Mallalieu runs where he shows the entity framework accessing sharepoint or some other schema that otherwise really doesn't fit the model.
    • UNICODE support in Entity SQL
    • Query plan caching and I'm pretty sure we do some metadata caching across app domains as well, but that may not be fully online yet in this CTP release.
    • Canonical functions in Entity SQL
    • Associations between sub-types -- This one is a biggy (as if the others aren't).  Before this change, the entity types that are on the ends of relationships had to be the base type of an entityset, but after this change you can define relationships between any types in the type hierarchy even if they aren't the base types.  So, for instance, if I have a hierarchy that has Customer and BigAccountCustomer, then I could create an entity type DiscountPolicy and a relationship that only relates BigAccountCustomers to DiscountPolicies not just regular customers.

    Orcas June CTP - is out there such CTP?

    The answer is yes! Definetely! Microsoft UK made a post:

    The Product Group have released an newer version of Visual Studio, but they aren't releasing it as a CTP. It is aimed at fixing a couple of problems for some targeted customers. The reality of this isn't tested or up to the quality of a proper CTP. You can still use this download, but it has some problems and it isn't supported for TFS. I would recommend waiting until Beta 2. Sorry for any confusion I have caused.

    You can download VPC image from http://download.microsoft.com/download/f/2/a/f2ac411f-acf9-42a7-a84f-3efc409bcd6b/VSTS_VPCJuneCTP.mht 

    Breaking Changes in .NET Fx Libraries (Update: 7/11/2007)

    LINQ to SQL: INotifyPropertyChanged and Column properties have changed, which generates 100+ errors in small projects. You'll need to recreate your LINQ to SQL classes with the renamed LINQ to SQL Classes template.

    LINQ to SQL: Jim Wooley reports in a comment that the System.Data.Linq.AttributeMappingSource and System.Data.Linq.XmlMappingSource classes have moved to System.Data.Linq.Mapping.AttributeMappingSource and System.Data.Linq.Mapping.XmlMappingSource respectively. [Note: MappingSource changed to AttributeMappingSource and XmlMapping changed to XmlMappingSource, and namespace prefixes added.]

    LINQ to DataSet: The System.Data.DataTableExtensions namespace has moved from System.Data.Entities.dll to System.Data.DataSetExtensions.dll so you must change references.

    LINQ to XML: Fixing "Could not load type 'System.Linq.Func`2' from assembly 'System.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'." exceptions requires adding a reference to System.Linq.DataSetExtensions.dll. This is probably a temporary expedient for the June 2007 CTP.

    (via OakLeaf Systems )

    Visual Studio 2008 (When to expect?)

    It is amazing how many improvements was made from VS 2003 to VS 2005. I remember the time when I was so anxious to touch new VS 2005. MS guys are working hard (and smart) to let us waiting new VS 2008 (Orcas) in same manner.

    ScottGu was very responsive to users' comments on his blog entry VS 2008 Nested Master Page Support and shares

    VS 2008 Beta2 should be available for free download in the next three weeks. It will support a go-live license (Posted on July 09, 2007)

    Also the date of big launch is known... as  Windows Server 2008, Visual Studio 2008 and Microsoft SQL Server 2008 Joint Launch Announced. It is Feb 27, 2008 in LA.

    While the launch events are scheduled to kick off on February 27, 2008, Visual Studio 2008 will be released before the end of the year.

    Hello "Jasper"

    I wrote about the couple new projects that was announced by Microsoft recently and I’ve installed “Jasper” and I had some free time this weekend to play with it.

    You may ask What is Jasper? The answer comes from documentation: 

    Microsoft® Codename “Jasper” is a set of components aimed at fulfilling the need for a rapid and iterative development experience for data. With “Jasper”, you are able to just point at a database and immediately begin coding against its data using intuitive, domain-specific data classes. No configuration and no source code generation are required. Jasper works with existing application frameworks (including ASP.NET, WinForms, and WPF) and existing, real-world databases.

    First thing I noticed is the first CTP comes with samples in Visual Basic and IronPython which is not the best way to impress C# fans J I haven’t given up and I kept investigating and I am going to share with you my findings.

    Working with Jasper is very similar to LINQ to SQL. Everything is done through DynamicContext class and using it’s methods GetQuery,  AcceptAllChanges, CreateQuery and many others . The difference is that in LINQ to SQL there is a class that extend DataContext class but in Jasper  DynamicContext class is compiled in MS assemblies. If you play with it you’ll notice there aren’t any properties that represents tables in underlying database. But this is code snippet from samples that comes with Jasper:

    Dim connectionString As String

    Dim context As Object

     

    connectionString = _ ConfigurationManager.ConnectionStrings("Northwind").ConnectionString

    context = DynamicContext.CreateDynamicContext(connectionString)

     

    '*** get Customer table by late binding

    Dim query As Query = context.Customers

     

    '*** bind to grid

    ResultsGrid.DataSource = query

    ResultsGrid.DataBind()

    Do you see the row that ends with context.Customers? On this row the content of Customers table is got and can be used in lines below to be bound to GridView control.  As we said the class DynamicContext is same for all applications and the tables are got using late binding because the Jasper data classes are generated dynamically at runtime when DynamicContext.CreateDynamicContext() is called.

     Late binding could be painful in C# and it seems this is reason not having samples in C# for nowJ.

    I will cover another feature in Jasper – dynamic queries. There is very easy way to construct queries in Jasper. All you have to do is using Microsoft.Jasper.Query class and it’s methods  Select, OrderBy, Where, Union ( and many others ):

    Dim query As Query = context.Customers

    query = query.Where("it.Country = 'USA'")

    query = query.OrderBy("it.CompanyName")

    query = query.Select("it.CustomerID, it.CompanyName, it.City")

     

    Dynamic queries are doubtful from architecture standpoint as they could harm the design and easy mess DAL code with business logic. This is why I recommend avoiding dynamic queries when possible or use them very carefully.

    This blog entry contains very little code but I can assure you this is enough to get Customer table content and display it in Grid control on ASP.NET page. J

    You can get Jasper from Microsoft Downloads.

    And don’t forget the prerequisites:

    1)      Microsoft Visual Studio® Codename “Orcas” Beta 1.  Install details can be found at http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx.

    2)      Microsoft SQL Server™ 2005.  The Microsoft SQL Server 2005 Express Edition can be found at http://www.microsoft.com/downloads/details.aspx?familyid=220549b5-0b07-4448-8848-dcc397514b41&displaylang=en.

    3)      (Optional) Microsoft Iron Python 1.1.  The install can be found at  http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=2573.

    Two more projects in MS with codenames

    ADO.NET blog announced that two projects has been set up inside Microsoft recently - both revealed at MIX 07.

    First one has codename "Astoria" and it's goal is

    to enable applications to expose data as a data service that can be consumed by web clients within a corporate network and across the internet. The data service is reachable over HTTP, and URIs are used to identify the various pieces of information available through the service. Interactions with the data service happens in terms of HTTP verbs such as GET, POST, PUT and DELETE, and the data exchanged in those interactions is represented in simple formats such as XML and JSON.

    The first early release of Astoria will be a Community Tech Preview that you can download, as well as an experimental online service you can access over the internet.

    Check out the Astoria webpage at http://astoria.mslivelabs.com for more information and a link to the download.

     

    Second one is called "Jasper" and aim at faciliating data-driven development. Developing data-driven applications could be tedios taks as developers have to spend a lot of time developing supporting infrastructure and Data Access Layer insead of focusing on real business problem. There are many O/R Mapping tools that reduce ammount of work by offering DB-classes mapping along with code generation. I personally though MS try to catch up with LINQ to SQL ( a.k.a DLINQ) and Entity Model in Visual Studio Orcas... but it sounds like they aim higher and use Entity Model for:

      • Dynamic generation of data classes so there is no configuration or design time code-gen to carry around.
      • Rich query and O/R capabilities because “Jasper” is built on top of the Entity Framework.
      • Auto-binding capabilities for ASP.NET, WinForms, and WPF to make binding data to a UI simple and automatic.

    Learn more about “Jasper” on the MSDN Data Access Incubation Projects site

    MS DevDays 2007

    Last week I attended at MS DevDays 2007 - the biggest event organized by Microsoft in Bulgaria. It was impressive as there were four tracks and dev track was so popular that MS decided to open another room where dev lectures could be read for second time :) This was good idea as devs were able to listen more lectures....

    This is not all... This year I learned some magic words :) Next Visual Studio Team System has codename - it is Rosario

    SQL Server team is working hard too on SQL Server Codename Katmai. The interesting part about it is that there will be Entity model build in it?!?! Yep, I suppose this will be the same Entity Framework that was dropped of VS Orcas release... as SQL team target developers too and they work on make our life easier when we develop data-driven applications.

    Here are some pics if the event:

     







    Thank you, guys for the interesting presentations!

    LINQ modules

    If you're C# developer you probably have heards about C# 3.0, LINQ, LINQ to SQL, LINQ to XML, LINQ to Entities and so on... Are you confused about these LINQ to XXXX stuff? Have you asked yourself how these modules are related?!

    This is very good diagram posted in in June issue of MSDN Magazine by Anson Horton (PM in C# team):

    Read full C# 3.0 overview.