DCSIMG
November 2008 - Posts - Ariel's Remote Data Center

November 2008 - Posts

PDC 2008 – All good things come to… a Beginning!

Posted Nov 24 2008, 04:45 PM by Ariel Ben Horesh  

PDC is way behind us, but we at Sela put on an effort to try to summarize the most important stuff from the event(atleast those we liked :)) for the rest of Sela employees and special guests.

We did that in a rather challenging way, since that 7  people (including myself) were attendees at PDC, each one of us got 15 minutes to talk about a few of his favorite subjects at PDC, like Andy Warhol famous quote, our 15 minutes of fame.

So in a tremendous pace all those people spoke up :

  1. Adar Wesly: Windows Azure, MONO.
  2. Alon Fliess: Windows 7.
  3. Ariel (that’s me): Dynamic runtime features on .net 4.0.
  4. Tomer Shamam: WPF 4.0.
  5. Josh Rueben : M, OSLO, PEX, Code Contracts.
  6. Noam King : Future of ASP.Net.
  7. Noam Sheffer : Live Mesh.
  8. Sasha Goldstein: Parallel and Concurrency for Manager and native.

I really enjoyed the fast movements between each subject, and we all just emphasized on the most important stuff (or just a sentence for a subject. that for the unbelievers) of each topic so in just 2 hours including pizza break all got really educated, a beginning to those who needed the extra push to go and learn tomorrow’s stuff.

I hope such gather away evenings would follow on different kind of subjects.

Ariel

Using PDC bits with new “Dynamic” features

Posted Nov 24 2008, 04:23 PM by Ariel Ben Horesh  

While preparing for a talk I am to give about the new C# 4.0 dynamic feature and dynamic languages in general I ran into several issues that I would like to document here, maybe they will be helpful for you as well.

I am using the Visual Studio 2010 VPC which was handed over for every PDC attendee. But don’t feel bad if you don’t have it, you may download it now (7.2GB download).

The VPC contains many walkthroughs you can try on, such as interoperability of IronPhython and C#, and Silverlight.

In order to do the those walkthroughs and also run the demos Anders and Jim did on their PDC sessions you need a few stuff that don’t come with the VPC.

  1. You must have an IronPhyton runtime which is not included with the VPC. You can download it from here.
  2. When you do try to install the IronPhyton runtime, the installer stops at "Please wait while the installer finishes determining your disk space requirements" phase. Following my past Vista UAC “instincts” I run it through command line with “msiexec /i  IronPython.msi” and it did work. (Thanks Vista!).
  3. While trying to reproduce both Anders Hejlsberg and Jim Hugunin examples from PDC 2008, you will notice that the DynamicObject object that they are using id missing. It just didn’t make it to the VPC. Luckily you don’t have to re-implement it, Curt Hagenlocher had provided us a copy of it.

Link to Curt’s post

Link  to Kevin Hazzard’s post.

Good luck!

Ariel

Entity Framework – Disappointment.

Posted Nov 17 2008, 10:56 AM by Ariel Ben Horesh  

For some time I am consulting one of my customers with the creation of WPF application which uses a Sql Server Compact edition DB.

We quickly used Linq to SQL as our DAL and created our data model (using SqlMetal as so far even after SP1 no IDE support for SqlCE, drop me a comment if you don’t know how to use it).

As with everything in life, Linq to SQL has it’s weaknesses but to tell the truth it just works. I’ve been able to put up a full working POC consisting of Composite application guidance and everything in just a few hours work.

Last week I’ve returned back after a short vacation, PDC and some nice work at Redmond.

One of the new things I found out after getting back is that there is a possibly new requirement, a need to work against DB2.

Thinking about the future in this project brought me to several conclusions:

  1. We would like to have one DAL.
  2. We would like to be able to work against SQL Server, SQL server CE and DB2
  3. We would like to be able to model our objects from those sources.

As you might suspect, Entity framework should be a good investment to obtain those conclusions written above. It should now support my development against SQLCE and when the time is right (assuming a provider for DB2 will be shipped) we will be ready for it.

So I started migrating our App to EF.

First Issue:

Linq to SQL:

When you would like to retrieve elements and their associated elements as well in one query, you would have to register it using DataLoadOptions object.

it is very convenient one line of code and setting it inside the DataContext factory and you no longer need to get bothered with it again. It just work.

Entity Framework:

The EF equivalent is using .Include() method with your query. Instead of supplying lambda expression which you got intellisense, this time you need to supply it with a string; the name of the table. This is error prone as hell, do I need to mention table name changes or just honest misspelling?

More cumbersome than that you need to add it to every query you run.

Got an arch object with a lot of associated entities, tough luck, Include got only one parameter so you need to chain them.

Include(“A”).Include(“B”)….Include(“Z”)

Again, for every query!

Second issue:

Linq to SQL:

Lucky for us the data of the app is readonly. We don’t need our DAL to keep track of changes, because there will be none.

So naturally we are using[DataContext].ObjectTrackingEnabled = false.

Entity Framework:

Unfortunately the EF corresponding object (ObjectContext)  doesn’t include such an easy option.

You need to manually check every table for it’s MergeOption and assign it to MergeOption.NoTracking.

I repeat for every table, if you have +100 tables, be prepared for a nice copy & paste finger exercise, who said developers only sit on our buts and do no physical exercises.

Third issue:

One of the key advantages of EF is the ability to model the entities differently than the db. You want to add an association using the designer. I was attacked with mind boggling errors such as :

Error    2    Error 3021: Problem in Mapping Fragment starting at line 1406: Each of the following columns in table XYZ_Product_CHILDTABLE is mapped to multiple conceptual side properties:
XYZ_Product_CHILDTABLE.AAAAID is mapped to <XYZ_Product_XYZ_Product_CHILDTABLE .XYZ_Product_CHILDTABLE .AAAAID , XYZ_Product_GRAPHICProductXYZ_Product_CHILDTABLE .XYZ_Product_GRAPHICProduct.AAAAID _ID>
XYZ_Product_CHILDTABLE.SuperProductID is mapped to <XYZ_Product_GRAPHICProductXYZ_Product_CHILDTABLE.XYZ_Product_CHILDTABLE.SuperProductID, XYZ_Product_GRAPHAlProductXYZ_Product_CHILDTABLE.XYZ_Product_GRAPHICProduct.SuperProductID>

Rough edges ah?

Fourth issue:

The last issue of many I am going to publish here is that a innocent looking query condition such as : Name == “Margol” raises this issue:

The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates.

Apparently there is a bug and somebody along the way thinks that my honest nvarchar Name column of mine is NText, so the == is not valid against it.

Reading this MSDN forum thread, will let us know that a solution has been  found and should be released in the near future, joy.

Well for me it was enough, I’m not to wait for it, I am back to Linq to SQL, and I don’t care of what the guys at ADO.net team are thinking.

See you next version.

Ariel

How to migrate from SQL Server to SQL Server Compact Edition.

Posted Nov 02 2008, 12:57 AM by Ariel Ben Horesh  

So you have decided that you want to incorporate SQL server CE into your application. I found out that almost every Smart Client or Desktop based Rich application need a way to cache data and Sql Server CE is a great tool to do just that.

Sql Compact Edition has a few advantages that might sway you if you still don’t think it is necessary. But the main problem most people while considering a transition to CE that you need to create a schema from an existing DB and the IDE lacks this ability up to now;
You just can’t run a “Create” script on it from the IDE.

To solve this issue you can use this simple nice trick: We will be using the Sync framework to build our local CE db for you.

To do so you need to open VS 2008 (SP1).

  1. Create a new project (doesn’t matter which one).
  2. Create New Item –> Local Database cache
  3. Choose your Connection to the source database
  4. Add the tables you want to create on your compact edition
  5. click OK.
  6. and here you go, the wizard will create the local Sql Server CE database file for you.

Good luck

Ariel