Chad#

Ramblings of a technology junkie.

November 2008 - Posts

ADO.NET EF v LINQ to SQL (take 2)

So after my first article covering the ADO.NET Entity Framework vs LINQ to SQL fiasco going on lately I got a some feedback from many sources who shared my pain so I thought I’d extend a second part.  To those that responded with the obligatory “ADO.NET EF is for pros, you just don’t know what you’re talking about,” – let me explain myself a little better.  I’m on Microsoft’s side here.  I’d really prefer them see make the right choice to get an even larger community for developing on their platform technologies.  This is not an anti-Microsoft campaign.

Recently Microsoft has posted another article about how “LINQ,” isn’t dead and that “LINQ to SQL,” is just going to be developed based on customer feedback.  I see two problems with this.  The first being that it seems like they’re getting a ton of feedback from their customers saying that LINQ to SQL is what they want.  Well if customers want it and they’re developing it, why is there an issue?  Seems like they’re just trying to soften the blow to the companies and individuals that have now wasted huge amounts of time.  I’m fully aware LINQ to SQL will never get the attention it needs, and why?  Microsoft recently announced Windows Azure which takes advantage of ADO.NET Data Services, which uses EF.  Meaning Microsoft is going to invest heavily in technologies they are personally using rather than the ones their customers are, it’s in their history.  As we’ve seen, history repeats itself.

I recently tried converting a existing ASP.NET MVC project of mine to use ADO.NET EF.  I figured since I used a pretty abstract DAL using the repository pattern this should be no problem.  However, using ADO.NET EF was a nightmare to say the least.  I couldn’t easily get tables using extension methods or generics.  I wasn’t able to use .Single() or .SingleOrDefault() extension methods without getting an exception and it made me actually make huge changes to my DAL.  After hours of frustrating coding sessions I finally had a working copy of my DAL hooked up with ADO.NET EF.  Suffice to say after using it for a few hours I quickly reverted to LINQ to SQL and never looked back.

Now is the time Microsoft.  As I said previously you’re forging along with a new Microsoft the likes of which have never been seen before.  Contributing to open-source projects, including un-forked open-source projects and even allowing people to download the source of the work you spend so much money on.  Many of us appreciate that and are glad to see you doing it.  I, as a customer will be sad to say I will be looking for alternate technologies if LINQ to SQL does not get the attention it needs.

Resources:
http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/

ADO.NET EF v LINQ to SQL

So with the recent news of LINQ to SQL going DOA a lot of those who have developed applications around it are probably hurting.  I myself was shocked to hear that Microsoft would do such a foolish thing.

This is one of the things that turns off people from using .NET and other Microsoft technologies.  Things like branding, constant change and constant name changing steers people away from using something new.  When people first come to the .NET Framework one of the features they may be looking for is LINQ to SQL because it has the most community backing right now.  Little do they know that the technology that pulled them in is now going away for something harder to use and with less community backing.

I think Microsoft has been doing a fantastic job lately with their developer technologies with things like ASP.NET MVC, ASP.NET AJAX, MEF and Dynamic Data all being openly developed on Codeplex and even including open source JavaScript library jQuery.  However, this has got to stop.

What they need to do is make LINQ to SQL make the base access library/framework for a data layer to data objects and make ADO.NET EF (named something else hopefully) the enterprise solution and extensions of LINQ to SQL.  Rather than creating parallel, redundant frameworks they could break apart functionality.  Making one framework better and one extending the other.

Microsoft, please don’t make the mistake you’ve done so many times in the past you’re finally on the right track – don’t screw it up now.

kick it on DotNetKicks.com
Posted: Nov 09 2008, 04:12 PM by Xtek | with 6 comment(s) |
Filed under: , ,
Having trouble starting Velocity host on x64?

I recently installed Microsoft Velocity client on 5 of my dedicated servers and I thought I’d give this distributed caching a try and see how it went.  The 5 severs are all running Windows Server 2008 Standard x64 with AD Services.  Installing couldn’t have been easier or have gone smoother.  So after installing Velocity on my 5 machines I went to the lead machine to start it.  Note, at this point I hadn’t setup the cluster yet I was just installing it on the machines.

   1: PS C:\Program Files\Microsoft Distributed Cache\V1.0> get-cachehost
   2:  
   3: HostName : CachePort           Service Name              Service Status
   4: --------------------           ------------              --------------
   5: VSERVER:22233                  DistributedCacheService   SERVICE DOWN

So far so good.

Next was to start the individual cache host…

   1: PS C:\Program Files\Microsoft Distributed Cache\V1.0> get-cachehost
   2:  
   3: HostName : CachePort           Service Name              Service Status
   4: --------------------           ------------              --------------
   5: VSERVER:22233                  DistributedCacheService   SERVICE DOWN
   6:  
   7:  
   8: PS C:\Program Files\Microsoft Distributed Cache\V1.0> start-cachecluster
   9: Unable to open store PartitionAccessor: System.DllNotFoundException: Unable to l
  10: oad DLL 'sqlceme35.dll': The specified module could not be found. (Exception fro
  11: m HRESULT: 0x8007007E)
  12:    at System.Data.SqlServerCe.NativeMethods.DllAddRef()
  13:    at System.Data.SqlServerCe.SqlCeConnection..ctor()
  14:    at System.Data.SqlServerCe.SqlCeConnection..ctor(String connectionString)
  15:    at System.Data.Cas.Main.SqlCeStore.OpenConnection(String connectionString)
  16:    at System.Data.Cas.Main.SqlStoreProvider.Open(String ownerId)
  17:  
  18: HostName : CachePort           Service Name              Service Status
  19: --------------------           ------------              --------------
  20: VSERVER:22233                  DistributedCacheService   SERVICE DOWN
  21: Start-CacheCluster : Unable to load DLL 'sqlceme35.dll': The specified module c
  22: ould not be found. (Exception from HRESULT: 0x8007007E)
  23: At line:1 char:18
  24: + start-cachecluster <<<<

Well –- that didn’t work.  You’ll see I used the cmdlet start-cachecluster this just goes down the list and uses start-cachehost on each cluster node.

I later found out that this is a known issue with Velocity and a temporary fix for CTP2 has been found.  Just download SQL Server Compact 3.5 SP! x64 and install it on your machine.  So after installing that I tried to run start-cachecluster again.

   1: PS C:\Windows\System32> start-cachecluster
   2:  
   3: HostName : CachePort           Service Name              Service Statu
   4: --------------------           ------------              -------------
   5: VSERVER:22233                  DistributedCacheService   SERVICE UP

Fixed!

So this is a known issue by the Velocity team and it will be fixed in the next version.

Posted: Nov 04 2008, 11:20 AM by Xtek | with 1 comment(s)
Filed under: ,
C# 4.0 New features – Part 1: dynamic type

With C# 4.0 actively in development I thought it would only be appropriate to start writing about the new features.  The first I’ll be visiting is the new dynamic type.

The dynamic type allows us to easily access an object type without statically knowing the type at code-time.  This means we can declare an object as dynamic at code-time without having to know anything about it.  This means we get no intellisense, code-time or compile-time feedback.  If a member/method is invoked dynamically that does not exist or something along those lines you will get a runtime exception of type RuntimeBinderException stating it could not find the symbol.  In order to allow the dynamic invocation of these members/methods it utilizes some things from the DLR (Dynamic Runtime Library) which actually runs as a normal .NET DLL on top of the CLR (Common Language Runtime).  Let’s see it in action.

We’ll start with something simple to get us going.

   1: static void Main(string[] args)
   2: {
   3:     dynamic dynObj = "Hello dynamic world!";
   4:     Console.WriteLine(dynObj);
   5:     Console.ReadLine();
   6: }

As you can see this looks pretty straight-forward.  We’re just declaring a dynamic type (dynObj) and setting it as a string type.  The output is as follows…

Hello dynamic world!

So you can see that we can treat it like a normal .NET object but with no intellisense or statement completion.  Time to check it’s actual type.

   1: static void Main(string[] args)
   2: {
   3:     dynamic dynObj = "Hello dynamic world!";
   4:  
   5:     Type dynObjType = dynObj.GetType();
   6:     Console.WriteLine(dynObjType.Name);
   7:  
   8:     Console.ReadLine();
   9: }

Outputs…

String

Exciting, I know.  What this tells us is that at run-time it’s being treated as a string whereas at code-time it’s treated like a dynamic type.  Something you can also get out of that code snippet is that I’m calling .GetType() on the object.  This could lead to some much more complex uses I just wanted to show the basics

I know my examples weren’t all super-exciting however I showed the basic ideas behind using a dynamic type.  Currently dynamic types can be used for generic type parameters, method parameters, method return types and so on.  They however have a few limitations on them.  For example – you cannot use the addition (+) operator on dynamic objects.  In the long run however, they give us much easier access to unknown incoming object types.  So instead of having to use reflection to crawl the type you could just use dynamic types instead… quite handy indeed.

Posted: Nov 04 2008, 10:48 AM by Xtek | with 3 comment(s)
Filed under: ,
Every blogger needs a home

I've been looking for a place to put my blog for quite a long time.  I've always been partial to running it on my own server or at home because I want it to be my area, and mine alone.  I later realized I'd rather help and be a part of a community.  So with the help of Joe Stagner www.misfitgeek.com I now have a blogging home -- thanks Joe!

So with that I'd like to introduce myself.   My name is Chad Moran and I'm a .NET/ASP.NET software developer.  I currently have a few private projects going and I'm self-employed.  At the time of this posting I'm 23 and writing my code from an apartment in downtown Baltimore, MD.  I've been involved with using .NET since Visual Studio was first launched to the public and have even attended a few Microsoft events around the US since then including the {Heroes Happen Here} event in Cary, NC.  As of late I haven't been too involved with the .NET community as a whole though I'd really like to start having an online sense in the community.

Anyway, thought I'd give some sort of introduction rather than appearing out of nowhere.

My stuff...
Stackoverflow profile

Posted: Nov 03 2008, 06:06 PM by Xtek | with no comments
Filed under:
More Posts