Friday, August 31, 2007

SQL Server 2008 Date and Time changes

  There are a number of date and time changes coming in the next version of SQL Server 2008 which is currently scheduled for release towards the end of 2007 or early 2008.

 Date and time are now a separate  data types which may make the argument to switch from competing DBMS a little easier. In addition to the new date and time data types, SQL also adds datetimeoffset data type and datetime2 data type.

Here are the highlights of the new data types

Data Type Notes Storage
Date aligns with .Net and SQL Standard data type, supports multiple formats 3 bytes
Time(n) "n" indicates milliseconds precision by default this value is 10 nanoseconds which aligns with windows. 3- 4 bytes
Datetimeoffset(n) Date time offset provides a "time zone aware" data type. date time offset take a parameter that contains the millisecond precision. Time zones from -14:00 to +14:00 are valid  8-10 bytes
datetime2(n) "n" indicates milliseconds precision by default this value is 10 nanoseconds which aligns with windows. 8-10 bytes

 

In addition to adding these new data types SQL Server 2008 also introduces changes in the built in functions, such as GETDATE(), DATEADD() and DATEDIFF() to support these new data types.

The date time changes are welcome additions to SQL server and provide a flexible platform on which to build enterprise applications.

Monday, August 27, 2007

Entity Framework Beta 2 and Tools CTP released

 The ADO.Net Team have released Beta 2 of the Entity Framework an the first Framework Tools CTP.

 You can get the details on the release at the ADO.Net Team Blog

XML Schema Designer

 I just saw that the first CTP for the XML Schema designer is available for download. The designer is a graphical tool for working with XSD schemas, It plugs into Visual Studio, and this CTP only supports VS2008 Beta 2. You can grab it here.

Some interesting LINQ resources

 I ran across Hooked on LINQ today while doing some research for a class I'm putting together for my co-workers on the .Net 3.5 features. It's a well laid out site with a ton of LINQ information, definitely worth a visit. 

 ScottGu's Blog is another great site, as always Scott provides a great deal of insight and examples.

Friday, August 24, 2007

LINQ to DataSets

Erick Thompson has posted an article on LINQ to DataSets. It's a great primer on LINQ querying ADO.Net DataSets. 

Thursday, August 23, 2007

LINQ misconceptions

 Time and time again I heard coworkers  that "X" (insert your favorite ORM tool) is far superior to LINQ in regards to ORM and time and again LINQ is not really about ORM. Yes LINQ to SQL has some ORM type features, but it's not really a pure ORM platform.

  LINQ is really, at least in my opinion, about the language query functionality. It gives .Net programmers the power to write queries against not only SQL objects but native objects and XML in a language they are comfortable working in.  LINQ really shines in when used to query object collections and XML, operations that would have previously taken a dozen lines of code and nested loops is now as simple as a query. To me that is the power of LINQ.

  Yes the SQL database modeling and LINQ to SQL is equally as compelling, but I think people are to wrapped up thinking in terms of ORM tools that the miss the real functionality or how it can be leveraged to solve real business problems today.

 So next time you here someone comparing LINQ to ORM, tell them it's not about ORM, it's about the query.

Monday, August 13, 2007

LINQ file info code

 Here is a LINQ sample in C# based on the VB.Net How Do I? videos. To set this up create a simple windows form application, add a DataGridView and dock it to the form.

Place the following code in the form load event handler:

System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

      watch.Start();

           var files = (from  file in Directory.GetFiles(Application.StartupPath)
              select file);

           var fileInfo = (from file in files
                          select new FileInfo(file));

           var myFiles = from file in fileInfo
                         select new FileOps { Creation = file.CreationTime, Name = file.Name };

           dataGridView1.DataSource = myFiles.ToList();

           watch.Stop();

           TimeSpan ts = watch.Elapsed;

           MessageBox.Show(String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
               ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10));

 

To use the object initializers with anonymous types add the following class nested in the form class:

public class FileOps
  {
      public string Name { get; set; }
      public DateTime Creation { get; set; }
  }

 

You'll notice we start looking in the application startup directory, just replace it with the directory of your choice to try other directories. You can comment out the timing code if you just want to run the sample without a message box.

Enjoy................

Wednesday, August 8, 2007

The declining value of customer loyalty

 I've been weighing the benefit of renewing my Infragistics NetAdvantage subscription over the past couple of weeks and I think for the first time since 2002 I will not renew may subscription.

  Here's the issue, I've been a loyal customer since 2002, provided feedback, reported bugs and endorsed the product to co-workers and manages. My managers have always went and purchased company licenses on my recommendation.  I really like the tools overall and they generally add value each release. That said, last year early renewal was $335 which is expensive but not unreasonable, this year $445, a hundred dollars difference. They also like to send the renewal requests incrementally, 20% then 10% then nothing off all about 30 days apart, seems to me it should be the other way around, 10% then 20% to keep loyal customers. 

  The price isn't the only issue. I used to receive notice of new releases and upcoming betas,now I get nothing. I actually asked why this was on their PM's blog, the answer was that they may not have a current email address. That's funny because they can certainly reach me for a renewal request.

  So I'm going to start looking around for something comparable for another vendor, one who may actually value loyal customers. 

Monday, August 6, 2007

.Net 3.5 gems

 So often when a new release of the .Net framework is upon us we hear about the new "shiny" pieces, which while important, doesn't convey the fact that other parts of the framework are receiving attention as well.

  A case in point is the OpenFileDialog, I noticed some new properties for SafeFileName and SafeFileNames which weren't there in 2.0. I'm sure there are a bunch of other enhancements and additions, some like these are probably there to support Vista.

 At any rate my hats off to the guys/gals who add the non "shiny" parts that make our jobs easier on a daily basis.  

Saturday, August 4, 2007

Visual Studio 2008

 I've had a chance now to spend a fair amount of time with Visual Studio 2008 and so far has been solid. Right now I'm spending a lot of time getting familiar with all the new C# 3.0 features. It's always a lot of work staying ahead of the changes. So far my favorite IDE enhancement has to be the WPF editor, it's come a long way since it's preview days. My favorite language feature has to be Linq or Language integrated query. This is a great addition and it has made one of those often tedious tasks easy.

 More than once I've had to compare the contents of two lists to determine what exists in one that isn't in the other. I'm currently working on an app that imports a file, this file is always appended to, so I just need to add the new items to my collection, linq makes it a snap, here's the code.

IEnumerable<string> entryQuery =
          (from s1 in entries
           select s1).Except
            (from s2 in currentEntries
             select s2);

           //update the current entries to reflect the additions
           foreach (string s entryQuery)
           {
               currentEntries.Add(s);
           }

I've seen and implemented Equals on the collection, but most of the time you end up with the same record multiple times, with linq on one copy of any item is added.