Wriju's BLOG

.NET, Cloud and everything

Sharing “var” across the method

One of the biggest limitation in “var” is that it cannot be shared across the methods. So if you are doing something using that keyword then you have to stick to the local. I was reading Alex’s Blog where he explained it very nicely,   Here is my implementation,   Create an Extension method  … Read more


Here I am going to compare the two technologies and point some missing areas.   Let us use the Northwind database and get the list of Customers from city London. The ADO.NET approach would be,   static void Main(string[] args) {     string sConn = @”ConnectionString”;     using (SqlConnection conn = new SqlConnection(sConn))     {… Read more

LINQ to SQL : Execution Architecture

In L2S query execution can be separated in two major areas. One is to fetching the data another is manipulating the data (update, delete and insert). I use one slide during my L2S demo and here it is,     Fetching data from database   LINQ is only from fetching the data from database. LINQ… Read more

LINQ to SQL : What is DataContext.Translate Method

DataContext’s Translate method converts existing IDataReader to an IEnumerable<T>. This is very useful when you may need to run raw SQL Query though System.Data.Linq. I am getting few similarities with DataContext’s ExecuteQuery.   How Translate works +++++++++++++ Assuming I am using Northwind database.     using (NWDataContext db = new NWDataContext()) {     DbConnection conn… Read more

C# 3.0 : Useful keyword “var”

People complain about the keyword “var”. Especially, when we use it with the strict programming language like C# in .NET. Developers also complain about the readability part of it. I totally agree with them, but the scenarios where there will be no options but the “var” when it comes to on the fly projection of… Read more

C# 3.0 : Joining two in-memory collection through LINQ

LINQ allows us to join different collection source provided we are mapping with two properties with the same type. It is easy, it is quick and it is concise.     //Create Employee Class class Employee {     public int ID { get; set; }     public string Name { get; set; }     public… Read more

C# 3.0 Feature Articles

With this exciting release of .NET Framework 3.5 I have been exploring its magic and sharing the finding with you. Here I am compiling all of them together for indexing,   C# 3.0: Vote for the keyword “var”   C# 3.0 Features: Automatic Property C# 3.0 Features: Automatic Property (Part 2) C# 3.0 Features: Automatic… Read more

C# 3.0 : Partial Methods

C# 2.0 and Partial class, in one of the amazing features to work with one class separated in multiple physical files. Not only that, it also helps us to extend designer generated code such as Typed DataSet, Designer generated code etc.   With this C# 3.0, we can now have partial method. Partial methods are… Read more

Architecture Journal Reader (Beta) is available for download

Another Windows Presentation Foundation implementation for the popular Architecture Journal is now available for download. So know about Ray Ozzie the Chief Software Architect of Microsoft – the most prestigious position in Microsoft which was captured by Bill Gates.   Project Astoria, S+S and many more. All the 13 published journals are available in nice… Read more

MSDN Virtual Labs : C# 3.0, Visual Basic 9.0, ASP.NET 3.5

Learn and for installation-free mode and get started with Visual Studio 2008.   MSDN Virtual Lab: Building Web Applications with Visual Studio 2008 MSDN Virtual Lab: What’s new in C# 3.0 MSDN Virtual Lab: What’s new in Visual Basic 9   Namoskar!!!… Read more

ADO.NET Entity Framework 3.5 Beta 3 Released today

Beta 3 of the ADO.NET Entity Framework, and a preview of ASP.NET 3.5 Extensions. Designed to make it even easier for developers to build data-centric applications and services regardless of the underlying data source, the ADO.NET Entity Framework is already gaining significant support from multiple database vendors and third-party providers, including Core Lab, Data Direct… Read more

C# 3.0 : Exploring Lambda Expression

I started playing with Lambda expression after the TechEd demo by Anders Hejlsberg. Couple of nice things I would like to share with you.   As there might be many definitions for Lambda expression but to me Lambda Expression is the concise way to write functional implementation for Anonymous Method. This is been used by… Read more

LINQ to SQL : Enabling .dbml file for WCF

LINQ to SQL is object relational model and .dbml file generates the class file for all kind of Create, read, update and delete (CRUD) through the mapping mechanism. Ideally this should allow us to enable it for WCF Service. But for that we have to manually add DataContract and DataMember attributes. We can use .dbml’s… Read more

Visual Studio 2008 Training Kit Videos on LINQ

Visual Studio 2008 Training Kit videos are now available on web. Get some real exciting presentations   VS2008 Training Kit: What’s new in C# 3.0? VS2008 Training Kit: What’s new in Visual Basic 9.0? VS2008 Training Kit: .NET Language Integrated Query (LINQ) VS2008 Training Kit: Using LINQ with Relational Data   For more detailed list… Read more

Visual Studio 2008 and LINQ Case Studies

Some of the early adopters case studies are now available,   Xcalia OpenNETCF Consulting Sogeti Group K2   Get some of the quotes from there,     LINQ is an object-oriented language and so fits perfectly with the philosophy of our product, which aims to make technical details of data access transparent to the developer…. Read more

Visual Studio 2008 Express ISO image download

As usual Express editions are free but this time you can take this and sit in a remote location and install Visual Studio with no Internet connections. Yes we can download offline .iso to avoid download & install pain. Please visit, http://www.microsoft.com/express/download/offline.aspx After downloading you can write them in DVD. This version includes all the… Read more

C# 3.0 : Evaluation of Lambda Expression to Language INtegrated Query (LINQ)

From code name “cool” to C# 3.0, it’s been a long journey for this amazing language with .NET Runtime. Here I am going to show you the evaluation step by step.   Let us assume we have generic list of integers and I need to find the even numbers from that list,   List<int> arrInt… Read more

LINQ to SQL: Working with hierarchical data

LINQ to SQL supports hierarchical data and you can easily create a query and get output from there. Let us take an example of Northwind database. Northwind has Category -> Products -> Order_Details tables. -> indicates one to many relationships here. So ideally for a Category can have multiple products and a product can have… Read more

LINQ to SQL : New method DataContext.GetCommand()

LINQ to SQL we can read the generated T_SQL query using DataContext.Log or SQLQueryVisualizer. But If you are working with WebProject the Log property not very much convenient as you have to use TextWriter to dump the generated T-SQL query.   In Orcas Beta 1 we had DataContext.GetQueryText which used to give us the generated… Read more

ADO.NET 2.0 : Fine tune your DataSet Performance

ADO.NET 2.0 offers us a unique feature through which we can make a real lightweight DataSet. This is very important and much neglected development practice to overlook the performance part. So when you have huge data and you are getting multiple hit this small tune may help you a lot.   Assume I am working… Read more

C# 3.0: Vote for the keyword “var”

You all probably know what is “var”. You might have a question why this new keyword is required in programming language like C#. One of the few strong reasons is to have an Anonymous Type stored in a variable. Whenever you have to initialize a type you have to mention the type before you give… Read more

LINQ to SQL Windows Form Binding Data Step by Step

LINQ to SQL designer in Visual Studio allows us to create mapped class using the drag and drop feature from Server Explorer. Now that is business object which ideally you could use as your datasource and from Visual Studio 2008. So let us have this step by step, Open your Visual Studio 2008 and create… Read more

LINQ to SQL : Some of the best BLOGs

Some of the best blogs on LINQ to SQL I found are available for great learning, Scott Guthrie The Famous LINQ TO SQL Series Part 1: Using LINQ to SQL Part 2: Defining our Data Model Classes Part 3: Querying our Database Part 4: Updating our Database Part 5: Binding UI using the ASP LinqDataSource… Read more

C# 3.0 : Anonymous Type and .NET Reflection Hand-in-Hand

Anonymous Type is nothing but the type which gets defined by CLR (not you). So that type is as rich as any other normal type. Probably the conventional way to find the components of an Anonymous Type through reflection would be clearer to us,   static void Main() {     //Anonymous Type     var anyType… Read more

Pattern’s and Practices Guidance Explorer

This is one tool which will help you to find anything and everything for what you might scratch your head.   This tool is amazing. Please go ahead and install from Download Download GuidanceExplorer build 20060926 http://www.codeplex.com/guidanceExplorer/Project/FileDownload.aspx?DownloadId=2716   This is the best Guidance you can get in your day to day programming.   Namoskar!!!… Read more

Visual Studio 2008 : How to add Visualizer for LINQ

There are two very important visualizers for LINQ which are not part of default installation.   The visualizers are Ø       ExpressionTree Visualizer Ø       SqlServerQuery Visualizer     Both the visualizers are available from   Visual Basic Samples for Visual Studio 2008 Beta 2   Visual C# LINQ and language samples for Visual Studio 2008 Beta 2  … Read more

LINQ to SQL : Change in DataContext from Beta 1 to Beta 2

During the demonstration I have noticed that two major methods of DataContext has changed from Beta 1 to Beta 2.   First one, is the new name for the class DataShape(). Now there is no class called DataShape() but we have DataLoadOptions().     var loadOption = new DataLoadOptions();            loadOption.LoadWith<Customer>(c => c.Orders);   db.LoadOptions =… Read more

LINQ to SQL : Paging Data

When we work with relational database and especially when with larger data we generally go for custom paging. This allows us to create superfast application.   The simple logic for paged query is like,   Let’s suppose you have 100 rows. Now you want to get data of page size 10 for page 2.  … Read more

Have you tried LINQPad (Beta)?

Experiment and learn new concept of LINQ. This is just an exe which requires no extra installation. Pre-requisites Install just .NET Framework 3.5 (minimal impact) Install Visual C# 2008 Express Install the full Visual Studio 2008 Download http://www.albahari.com/LINQPad.exe For more information please visit, http://www.albahari.com/linqpad.html Aha this is from my screen,   Namoskar!!!… Read more

LINQ to SQL : Using Transaction

LINQ to SQL uses optimistic concurrency be default. LINQ to SQL is pure in memory operation, because you normally get the data from database and store them in .NET memory and perform some pure in memory update to those objects and finally when you are done with your modification you give those data back to… Read more

MSDN Magazine : Data Point Articles

Data Points: ADO.NET Entity Framework Overview Data Points: Contrasting the ADO.NET DataReader and DataSet by John Papa Data Points: Data Bound Applications with ADO.NET and Custom Objects by John Papa ADO.NET: Tackle Data Concurrency Exceptions Using the DataSet Object by David Burgett Data Points: DataSet and DataTable in ADO.NET 2.0 by John Papa Data Access:… Read more

Visual Studio 2008 Beta 2 is here

Choose the one you want Visual Studio 2008 Standard Edition Beta 2 Visual Studio 2008 Professional Edition Beta 2 Visual Studio Team System 2008 – Team Suite Beta 2 Visual Studio Team System 2008 – Team Foundation Server Beta 2 Visual Studio Team System 2008 – Test Load Agent Beta 2 MSDN Library for Visual… Read more

LINQ and C# 3.0 Articles and Samples

LINQ: .NET Language Integrated Query By Don Box, Anders Hejlsberg LINQ to SQL: .NET Language-Integrated Query for Relational Data By Dinesh Kulkarni, Luca Bolognese, Matt Warren, Anders Hejlsberg, Kit George .NET Language-Integrated Query for XML Data By Michael Champion The .NET Standard Query Operators By Anders Hejlsberg, Mads Torgersen Overview of C# 3.0 By Anders… Read more

LINQ to SQL : Object Relational (O/R) Model

LINQ to SQL is pure Object Relational Model introduced by Microsoft. It used mapping mechanism to represent   Relational Components Object Component Table Class Column Property Foreign-key relationship Association   It gets the user input through this object model and gives the translated value to SQL in form of pure T-SQL query and when query… Read more

LINQ to SQL : Caching the query execution

LINQ to SQL executes or generated SQL statement only when you run a foreach statement or you perform to ToList() method to it. If you need to display the output multiple times without executing the real database query, you can store them in memory. This can be done only when you are sure that the… Read more

LINQ to SQL : Deferred and Immediate Loading

LINQ to SQL has support for both deferred and immediate loading. By default it supports deferred loading but you can configure your code to load the data immediately. Let’s consider the Northwind database. As we know the there are two tables Customer and Orders and one customer can have multiple orders. These two tables have… Read more

Celebrating my 100 posts!!!

Thanks to everyone who supported me in this BLOGGING journey. I started blogging back in May 2006, was not very regular blogger till September 2006. I blog to share my .NET adventure, starting from C# 2005 to LINQ (C# 3.0). I use them to convey the interest for others.   In Microsoft I work for… Read more

LINQ to SQL : Writing DML query to perform quick operation

In LINQ to SQL you also can send the DML query to perform the quick database modification.   Caution!!! It is not recommended as it does not support object model so has no compile time checking.   static void Main(string[] args) {     string strConnection = @”Data Source=wriju-orcas\sqlexpress;Initial Catalog=TestDB;”;       TestDB db = new… Read more

LINQ to SQL : Delete data through Object Model

LINQ to SQL support deleting data through object. Continuing with my previous blog on INSERT, let me discuss about the delete method   static void Main(string[] args) {     string strConnection = @”Connection String”;       TestDB db = new TestDB(strConnection);       db.Log = Console.Out;             //Here I am finding the employee with… Read more

LINQ to SQL : Update data through Object Model

LINQ to SQL support updating data through object. Continuing with my previous blog on INSERT, let me discuss about the update method   static void Main(string[] args) {     string strConnection = @”Connection String”;       TestDB db = new TestDB(strConnection);         //Here I am finding the employee with Id 19     var updateQ… Read more

LINQ to SQL support inserting data through object.

LINQ to SQL support inserting data through object.   using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Linq;   namespace Linq2Sql_demo_doc {     /// <summary>     /// Class to represent the SQL Server table     /// Emp     /// Id int     /// Name varchar(50)     /// </summary>    ///     [Table(Name=“Emp”)]     public class… Read more

LINQ to SQL : Executing DML SQL Query

INSERT/DELETE/UPDATE can be performed in LINQ to SQL through normal T-SQL DML queries,   static void Main(string[] args) {     NorthwindDBDataContext db = new NorthwindDBDataContext();   var query = db.ExecuteCommand(“YOUR DML Query”, “Your    Parameter”);       ObjectDumper.Write(query); }   Are you feeling comfortable? Hold on, please try to avoid this as you have better object… Read more

LINQ to SQL : Executing SQL Query

Yes, you can run normal SQL queries in LINQ to SQL. Sample looks like (but not recommended as you do not have statement completion and validation)   static void Main(string[] args) {     NorthwindDBDataContext db = new NorthwindDBDataContext();       var query = db.ExecuteQuery<Customer>(“SELECT * FROM Customers”, “”);       ObjectDumper.Write(query); }   One of… Read more

Visual Studio Team System Chat – July 3rd

Join members of the Visual Studio Team System product group to discuss features available in Visual Studio Team Foundation Server, Team Editions for Architects, Developers, Database Pros, and Testers. In addition, discuss what’s new in the upcoming Orcas CTP. We will be holding two sessions: Join the chat on Tuesday, July 3rd , 2007 from… Read more

ADO.NET Entity Framework June 2007 CTP is available

Overview This CTP contains updates to the ADO.NET Entity Framework since the Visual Studio Codename “Orcas” Beta 1 release, including changes in Object Services, Query, Entity Client, and the Entity Data Model Wizard in Visual Studio. Some of the new features include IPOCO, detaching from long-running ObjectContext instances, multiple entity sets per type, support for… Read more

LINQ: Query to SQL, XML and Object and JOIN them

Getting data from SQL, XML and Object and joining them using Language Integrated Query is something you might be looking for. I have created a small application which brings data from SQL Server (table name is Employee), XML (file name is Department.xml) and Object (Generic list containing list of Managers).   My SQL Table Looks… Read more

30 years of wait and Bill kept the promise he made to his dad

I’ve been waiting more than 30 years to say this: “Dad, I always told you I’d come back and get my degree.” – was the first reaction when this most wanted man in the software industry received much awaited degree. It took 30 odd years for conventional education system to understand the potential of a… Read more

2008: Microsoft will rule

Be ready from 2008. Set of products from Microsoft are releasing then.   Windows Server 2008 SQL Server 2008 Visual Studio 2008 are the few names and so many other related technologies based on these major products.   So be ready and start upgrading yourself. Browse MSDN/TechNet and know more about these products. Talk about… Read more

Visual C# 2005 Default Shortcut Keys

This is one of the articles I wanted to write long back. May be it is not too late. These shortcut keys helps us to make our life easy.. Visit http://msdn2.microsoft.com/en-us/library/ms366739(VS.80).aspx Global Shortcut Keys, Visual C# 2005 Scheme HTML Designer Shortcut Keys, Visual C# 2005 Scheme XML Designer Shortcut Keys, Visual C# 2005 Scheme Control Manipulation… Read more

Surface Computing

Use your restaurant table to give order. Put your credit card in the table for payment. Once you are in business meeting and both of you are carrying blue-tooth enabled mobile phones can share your business data. All in your good old normal table with abnormal activities. Surface Computing by Microsoft. Visit for more http://www.microsoft.com/surface/… Read more

Moving from Orcas CTP to Orcas Beta 1

If you have Orcas March 2007 CTP and you want to upgrade it to Orcas Beta 1, there are couple of things to be taken care. Those are well documented in MSDN and you need to clean all the CTP related installation to enjoy the smooth installation. Components which could create problems are, Remove “Microsoft… Read more

C# 3.0 and its major design changes for LINQ

C# 3.0 PM Anson Horton discussed about the LINQ and its impact on C# 3.0 covering Lambda Expressions Extension Methods Anonymous Types Implicitly Typed Local Variables Object Initializers Query Expressions Visit the MSDN Magazine article at http://msdn.microsoft.com/msdnmag/issues/07/06/CSharp30/ Namoskar!!!… Read more

.NET Framework: Understanding Green Bits and red Bits

In lots of articles about .NET Framework 3.0/3.5 you might find the term called Green bits or Red bits. What is that all about? Must read this article to understand the architecture,  http://www.danielmoth.com/Blog/2007/06/net-framework-35.html  Let’s also use the picture from that blog Namoskar!!!… Read more

Linq Performance

LINQ is powerful, the internal algorithm has got the power for fine tuning and PLinq is in the pipeline. That means if you will have automatic implementation of parallel LINQ for multi-core processors. Two famous quotes from Anders Hejlsberg are   “With PLinq, effectively you write the code the same way, but we arrange for… Read more

SQL Server 2008 (Katmai) June CTP Released

Related resources,  Read the SQL Server 2008 Datasheet SQL Server 2008 Product Overview Watch the TechEd SQL Server 2008 Webcast Download the latest release And may more such exciting at Tech Ed 2007. http://virtualteched.com/Pages/OnlineSessions/OnlineWebcastsDefault.aspx Namoskar!!!… Read more

ASP.NET 2.0 Membership, Roles, and Profile

From 4GuysFromRolla This article is one in a series of articles on ASP.NET 2.0’s membership, roles, and profile functionality. Part 1 – learn about how the membership features make providing user accounts on your website a breeze. This article covers the basics of membership, including why it is needed, along with a look at the… Read more

Linq: Why and Its Contemporary

Why LINQ (or other components of Linq). One of the major reasons is that to address the mismatch between relational data domain and object domain. Database was more comfortable for developers from SQL world and they were no where in object domain. Please visit Comparing LINQ and Its Contemporaries for more details. Namoskar!!!… Read more

Performance in C#

When we consider managed code in our application we also have to think about the performance. .NET has its own way of fine tuning things but just by remembering couple of things we can prevent the unnecessary push backs from our end. One of the biggest concerns is that why Generics? It is strongly typed,… Read more

Astoria Next Generation of Data Access for Web

Project codename “Astoria” is to enable enable applications to expose data as a data service that can be consumed by web clients within a corporate network and across the internet. The data service is reachable over HTTP, and URIs are used to identify the various pieces of information available through the service. Interactions with the… Read more


Formally known as WPF/E, Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of Microsoft .NET–based media experiences and rich interactive applications for the Web. Find out more resources from MIX. To be  updated keep on checking Microsoft Silverlight Namoskar!!!… Read more

MIX 2007 Session

MIX07 sessions are now available for offline viewing. This download is available in both wmv and for Zune or else you can play it using Silverlight (the scale down version of WPF known as WPF/E). http://sessions.visitmix.com/  Recommended session, DEV04 – Using LINQ to Dramatically Improve Data Driven Development in Web Applications by Anders Hejlsberg Namoskar!!!… Read more

Orcas Beta 1 ADO.NET vNext First Look

What is ADO.NET vNext or Entity Framework? It has been a long journey for the application development and data access. Starting from DLib,… DAO, ADO, ADO.NET. Now the world is for ADO.NET vNext or Entity Framework model. This is to increase the level of abstraction and avoid the change mismatch. In Orcas the designer is… Read more

Design Patterns Resources

A nice site at http://www.dofactory.com/Patterns/Patterns.aspx     Creational Patterns   Abstract Factory   Creates an instance of several families of classes   Builder   Separates object construction from its representation   Factory Method   Creates an instance of several derived classes   Prototype   A fully initialized instance to be copied or cloned   Singleton   A class of which only a single instance can… Read more

Cω Overview

Do you know there is another language called Cω? This is still is experimental stage and the future plan is yet to be decided.   This is targeted for concurrent programming. The approach will be more easy and user friendly. Application programmers also will be able to implement on concurrent programming which now only the… Read more

C# 3.0 Enhancements: Expression Trees (recording)

I have discussed about the Expression Trees in my previous blog at C# 3.0 Enhancements: Expression Trees. I have done a small recording on that showing the demo there. I have uploaded that to MSN Soapbox and you can find that here.   Video: CSharp 3.0 Expression Trees    Namoskar!!!… Read more

C# 3.0 Enhancements: Expression Trees

Expression Tree is the feature which enables us to write function which can be complied on-demand basis. It stores the function in form of structured data rather than executable code. Since this is structured we can easily iterate through it anytime. This is easier than finding something in IL.   Let’s suppose if you have… Read more

Linq to Object: Play with OS Component

  Linq not only allows us to work with .NET objects but also gives us the power to play with OS components like EventLog, Registry, Processes etc. If you plan to develop tool which will monitor the system process activities and will notify admin if there is any unpredictable things happening. It is all about… Read more

C# 3.0 Enhancements: Lambda Expression (more on what)

Lambda Expression gives us the more concise way of Anonymous Method implementation through functional programming language. Let me share some interesting aspects of Lambda Expression while exploring the C# 3.0 Specification. There it is being clearly described what Lambda Expression is.   (param) => expr   Can be expressed as   param => expr  … Read more

C# 3.0 Enhancements: Collection Initializers

In C# 3.0 we can easily initialize collection. It is smarter and concise way of writing code.   There are couple of things we should consider while initializing the collection. Ø       The collection should implement ICollection<T> Ø       The collection should have a provision to invoke ICollection<T>.Add(T)     Here is couple of them. I am… Read more

C# 3.0 Enhancements: Extension Methods

Extension Methods are different way of implementing static method. In C# 3.0 it allows us to extend any type and add method for that type. While writing extension method you need to Ø       declare a public static method Ø       the first parameter of that method should be the type of the object Ø       “this” keyword… Read more