LINQ to SQL - Not Dead

Monday, November 3rd, 2008 | .NET, General | No Comments

For those who are not aware, last week there has been some misunderstanding regarding the future of LINQ to SQL based on announcements made by MS at PDC. Well after reading a few blogs around the Blogosphere I have come accross the following posts which explain that there is future for L2S:

Read Damien Guard’s blog ->http://damieng.com/

Read Huagati’s Blog -> http://blog.huagati.com/res/index.php/2008/11/03/quiet-blog-gone-fishing-is-linq-to-sql-dead-etc/

Further I found this cool image supporing L2S here

Long live LINQ to SQL !!!

Long live LINQ to SQL !!!

Tags: , , ,

LINQ query to get all the column names in the DBML tables

Friday, October 31st, 2008 | .NET, SQL | No Comments

// LINQ query to get all the column names for every Table
var model = new AttributeMappingSource().GetModel(typeof(ReportDBMLClassesDataContext));
int i = 0;
ArrayList lblList = new ArrayList();
foreach (var mt in model.GetTables())
{
i++;
Label lbl = new Label();
lbl.Text = mt.TableName.ToString();
lbl.ID = “lbl” + i;
Panel1.Controls.Add(lbl);
Panel1.Controls.Add(new LiteralControl(”<br>”));
int r = 0;
foreach (var dm in mt.RowType.DataMembers)
{
r++;
Label rlbl = new Label();
rlbl.Text = dm.MappedName.ToString();
rlbl.ID = “rlbl” + i + “” + r;
Panel1.Controls.Add(rlbl);
Panel1.Controls.Add(new LiteralControl(”<br>”));
}
}

Tags: , , , ,

The Life Aquatic with Bruce Mozert

Friday, September 5th, 2008 | General | 1 Comment

Check some of these amazing underwater photos (B&W) taken by Bruce Mozart, who apparently is the world’s first under water photographer.

Very impressive!!!

The Life Aquatic with Bruce Mozert | Photo Gallery

Tags: , ,

Dynamic Data Entities Web Application

Monday, August 25th, 2008 | .NET | No Comments

Today, I started playing with the new Visual Studio 2008 Service Pack 1. The download was massive (800mb) and installer wanted 4 gb free, so as a few people around the web have been saying it is almost like a new release (read Visual Studio 2009).

Any ways, coming back to the Dynamic Data Entities, I first saw a glimpse of this feature in Sql Sever 2008 presentation (read my prev. post), and was thinking this is cool, so gave it a go…It was simple in VS 2008 with SP1 you basically go to File > New > and chose ‘Dynamic Data Entities WebApplication’ project; VS gives us the usual web application template along with a new folder called “DynamicData” and this folder contains all the files required to generate dynamic data drive web application. Next click on Add New > ADO.NET Entity Data Model and follow the steps in the wizard. At the end of this step you will have a simple Entity model of the various table from the SQL Server.

With the entity model in place all we have to do now is edit the Global.asax file and read the instructions which are in the comments. I have put in the name of my model and chose true for ScaffoldAllTables.

model.RegisterContext(typeof(MyEntities), new ContextConfiguration() { ScaffoldAllTables = true });

With that step done…did the build and lo..and behold you get this simple interface which lists all the tables in the model and gives the user the ability to page thru the data in each table by rendering the data in Grid View and gives the options to perform CRUD (Create/Read/Update/Delete) operations. The cool thing is till now I haven’t done any code except for editing the above one line.

Search Feature

This is one thing that is currently missing in the entity driven web app. Currently I am investigating how I can implement this feature. If any of you know how, please let me know.

Tags: , , , , , , ,

SQL Server 2008 - my thoughts….

Tuesday, August 12th, 2008 | SQL, Technical | No Comments

I have been reading about SQL Server 2008 for a while and today I got a glimpse of the various features and how it can help developers at the Victoria Dot Net users group meeting. Thanks to the special presentation by Chris Hewitt - “What should developers know about SQL Server 2008?”

A few days ago, I read about the new “File Stream” data type and my initial thoughts were how would I use this new feature and where would this be more usefull, later I realised that I could use the FileStreaming data type to store all the various CSV reports that I generate from our various applications. So effectively instead of storing it on a file server and putting in the reference in SQL, I could easily store the entire CSV file in to SQL Server and let it worry about where and how it stores it. More over I can also have all the report metadata in one location (sweet :).

In the presentation Chris showed us a few examples on how we can send a Table as parameter to Stored Procedures and the new Merge Statement.  Well, frankly speaking it took me a few seconds to comprehend the huge benifits of sending in a table as a parameter to a stored procedure. The biggest benifit is the ability to insert large number of rows in one go by passing the data as a table parameter. Previously you could do that with temp tables but those tables were only specific to the stored procedure which creates them, however with this new feature we have some thing on the lines of Global Temp Tables. For more detailed explanation and examples, please refer this article

Coming to the Merge statement that’s another cool feature that has huge number of benefits. In scenarios where you need to to insert, update, or delete data based on certain conditions, programmers have to take care of the actions in the application, however with Merge statements we can do the insert, update or delete in one single statement based on the join conditions. For more information, please refer this article at BuilderAU.

Another cool feature is the Filtered Indexing. As the name suggests, all it means is that when we create Indexes for a table in SQL Server 2008 based on a particular criteria (simple where clause). I am very keen to test this on one our biggest tables (9 million rows and counting). At the moment  it takes quite a bit of time to query this table for certain criteria, I would love to do some bench marking on this table and see how efficient the Filtered Indexes are.

Finally a one more interesting feature is the ability to Debug Sql Statements in the same way as .NET code. Chris showed how we could debug any SQL statement or Stored procedure, and also the MS has finally introduced Intellisense for SQL statements. Allthough I have been told that 3rd party tools have been providing SQL intellisense for quite some time now.

For those of you who are interested in other features like Sparse, new DateTime formats, new Convert functionality etc, please refer SQL Server 2008 @ Microsoft.

Tags: , , , , , ,

Search

Pages