Wednesday, 5 August 2009

Linq-to-Sql multiple views of the same data

In my previous post I mentioned the problems I have been having with Linq-to-Sql so I thought I'd elaborate on my difficulties.

Before now I hadn't used Linq-to-Sql but had seen demo's, web casts, etc that made it seem all so easy so I started work with high hopes. I set about adding a linq-to-sql file to the solution opened up the server explorer and added a table, all went well, but it was about to all go down hill rapidly.

Up to now I've done the majority of data access using stored procedure and was used to getting data from a table in any shape I wanted. My first problem with Linq-to-Sql was that I wished to have different views of the data in a single table and thought I should easily be able to define these views but this functionality simply is not available.

Now in linq's defence I don't remember it saying is should allow this type of functionality but as I said I had high hopes, I did find I could drag as many instances of single table into the model (got warning messages when I built but no other apparent problems) and I could then remove fields add properties etc but it felt wrong.

So for now this is what I've done, don't know if its the best or only way but will do for now.

No comments:

Post a Comment