Contents tagged with SQL
Straight after listening to the show, with the advice of Scott Cate (a promotion code), I hot stepped over to http://easydb.com to sign up. After waiting for a few days, maybe a week and still having heard nothing I tried again and was greeted with this little chestnut...
...and that remains to this day.
Why bother doing a dnrtv episode then not letting me in to try it, blog about it and generally test it???? Pointless...
Anyone else using this beta that may have the power to let me in?!?!
You are all undoubtedly aware of LINQ to SQL, its fair to say its had a large amount of publicity and coverage in the .net circle. VS 2008 makes getting going with LINQ to SQL very easy but that is not the case with SQL Compact (yet!). However its not difficult if you have heard of a wonderful little app called SqlMetal, this little beauty will generate the .dbml files for you...happy days :)
I have a small SQL Compact database to use for this demo, you can see it here in VS 2008 server explorer...
Run VS 2008 Command Prompt, navigate to the location of your .sdf file (you can of course run SqlMetal using the full file path to the .sdf but I just prefer the prior) and type...
>SqlMetal SqlCeFileName.sdf /dbml:LinqClassName.dbml
That will create the dbml file in the same directory as the .sdf file, now add it to your project in the normal way.
You can open the .dbml file in the same way and you will get the VS 2008 designer because its doesn't care what provider you are using (SQL CE) that will be sorted at runtime - right now you are just looking at a .dbml file.
You can now use LINQ in the same way as you would for SQL Server...
Tageditor te = new Tageditor(TagEditor.Properties.Settings.Default.TagEditorConnectionString);
Note: I am passing the location to the SQL Compact database file to the constructor of the LINQ class ( "Data Source=|DataDirectory|\\Data\\TagEditor.sdf" ), as I said before, I don't need to specify anywhere that the provider is SqlCE, that is inferred at runtime! :)
You can now use LINQ in the same way to work with your database - I wont go into LINQ here, there are plenty of resource around to view...here are a couple I found useful.
ScottGu's 9 part series on LINQ - all you need to get going really.
SQL Compact Edition