Databases



Is Microsoft going to kill LINQ to SQL (L2S)?  The rumors are that Entity Frameworks (EF) is the database plan of choice now and L2S is out the door.  There have been a few posts on the topics, here are a couple: http://codebetter.com/blogs/ david.hayden/archive/2008/10/30/linq-to-sql-gets-kicked-to-the-curb-needs-a-good-home.aspx http://ayende.com/Blog/archive/2008 /10/31/microsoft-kills-linq-to-sql.aspx Personally, I think if they just added some method of change tracking to the entities and made disconnected work easier, then L2S would be pretty hot.  I do not like passing around connections (DataContext’s) to different layers and prefer to work in a disconnected form.  Of course, this means you...




SQL Server 2008 is now RTM!  Truth be told, I have not kept up on the changes now bothered with the betas.  The article that mentioned it was RTM had a link to this article of a quick overview of changes in SQL Server 2008: http://technet.microsoft.com/en-us/magazine/cc434690.aspx http://blogs.microsoft.nl/blog_van_mark_voermans/archive /2008/07/15/sql-server-2008-ships-in-august.aspx   A few things that jumped out at me: Compression at row or page level Merge - Insert/Update rolled in one (no more check to see if record already exists and the update if it does, otherwise insert the new row,...




Found this set of articles on LINQ to SQL.  The articles contain some interesting concepts and a good overal! Part 1: Querying View entities (ObjectDumper) View SQL statements (Log & Visualizer) Local data shaping Non-mapped properties in partial entity classes Object Relation Diagram versus Class Diagram Data shaping with non-mapped properties Change tracking Bulk operations http://www.scip.be/index.php?Page=ArticlesNET02&Lang=EN  Part 2: LINQPad Inheritance ...




This is an older article I happened to find recently that opened a few more areas of thought about LINQ.  Yes, I know LINQ is used for many things, not just data storage, XML or easy of collection handling.  That said though, I really did not thnk about it in the use of a type of logic parser.   What a good idea! This is article gives examples of how to use LINQ to reduce the coding and complexity of scoring Yahtzee results on dice.   Pretty cool! http://www.c-sharpcorner.com/UploadFile/mgold/Yahtzee LINQ07222007010520AM/YahtzeeLINQ.aspx  




Just spent another couple days trying to track down and work around an issue I was having with LINQ 2 SQL and the current entity structure that is used.  The problem is basically, the change tracking routines to keep up with what changes you have made to an entity, is handled by the DataContext and not in your entity.  If you close your DataContext, you will have no change tracking.  Even worse yet, you will have problems "attaching" that instance to a new DataContext unless it is truly detached and you have a copy of the original data that the...




Here is a handy little tool to play around with: http://www.albahari.com/linqpad.html It allows you to play around with LINQ queries against your database in a friendly manner. 




I have heard a number of developers fear that LINQ 2 SQL would cause less mature developers to employ bad practices.  That is a very likely thing to happen as this new technology makes it easy for novices to build database access.  We just do not need to throw the baby out with the bath water, in professional environments, management will need to keep an eye on issues.   If managed properly this should not be an issue, but unchecked, you could end up with a mess! Today, I was playing around with navigating related tables.  I built three simple tables and...




Just spent a number of hours trying to figure out why my Linq was not updating my foreign key when adding a record with a one-to-one relationship.  Do not know if it is an issue or by design, but it took me a while to try the obvious.... Here is the simple tables I was using in this test:     Table Contacts (    Contact_ID [int] IDENTITY(1,1) NOT NULL,    CreatedAt] [datetime] NOT NUL,    FullName [nvarchar](128) NOT NULL, CONSTRAINT [PK_Contacts] PRIMARY KEY CLUSTERED (    Contact_ID ASC ) Table Comments (    Comment_ID [int] IDENTITY(1,1) NOT NULL,    Contact_ID [int] NOT NULL,    LastEditedAt [datetime] NULL,    Comment  [nvarchar](1024) NULL,  CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED (    [Comment_ID] ASC,    [Contact_ID] ASC )  Table AdditionalInfo (    Contact_ID [int]...




I ran into another problem with Linq and the Orcas beta 1 of Visual Studio.  It seems the code generated for your data classes may not contain a limiter on update checks which can give you the error: "SQL Server does not handle comparison of NText, Text, Xml, or Image data types" In my case, the field was a nText data type.  In the designer I can see that it is set to "Update Check" as "Never", but it appears that does not get saved in the code.  To solve the issue, I simply added the setting manually to the generated code on...




Linq is pretty cool along with Linq 2 SQL.  Although  I have actually not read a great deal on Linq, I jumped in and started building out a  project to test the waters.  Much easier to see how much you can pick up before formal study. Well, many things just clicked and I found quite of bit of it fairly easy.  Select, insert, update, delete all pretty easy.  For the project I did not want to turn to one SQL statement, no stored procedures or anything like that, just the Visual Studio Orcas and Linq. I got hung up on a simple...




Well, today I was working on building out he SIlverlightCity website and instead of using my old dataset/table adapter mehtods of the past in my data layer, I decided I would play a bit with Linq 2 SQL and see how it worked out.  After a few minutes, I can see I will not need to mess around with dataset/table adapter stuff for most work, Linq more than fits the bill. It is so easy to query, update, delete, etc, without all the extra work, not to mention that the Linq to SQL designer in the Orcas 1 beta is pretty...




For the last couple of days I have did some research to see if using the Full Text search indexing features in SQL Server 2005 Express would cause much overhead in the actual database file since there is a 4 GB limit with this version.  I did not want to plan solutions around SQL Server Express using Full Text if the limit could not handle it. During the process I ended up posting three new tips on my site www.HintsAndTips.com: SImple getting started with full text uisng the Express version Helpful Info on SQL Express 2005 when first using Full Text Search! Reminder to...




If you are running into long running opperations inside SQL 2005 Server Management Studio such as building indexes performed through the designers, there is a simple fix.  Today I spent about an hour digging for the problem since it did not follow the connection properties for the timeout and I could not rebuild an index without this timeout which seemed to default to 30 seconds. After some frustrating digging and not finding the answer to: 'myTable' table- Unable to delete index 'IX_PrimaryIndex'.  Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. I decided to...




Most people already know you can now write stored procedures in .NET with SQL Server 2005 (and Express), but there are other enhancements that many may miss.  Here are a few I have run into lately. * XML data type.  XML is now a legitimate data type you can assign as a column in a table, return in a result set or pass as a parameter to a stored procedure.  It is now simple to use XML in SQL Server on about any level. * Data type limits have been super-sized! Data types such as char, nchar, varchar, nvarchar and varbinany, can now specify "MAX" length...