• Wriju's BLOG

    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 it to run on multiple CPUs”


    "It doesn't necessarily mean that every program is going to run six times faster, but there are classes of programs that we can make run faster without the user having to get into the nitty-gritty business of writing concurrent constructs,"




    Things to remember



    Ø       When you will work with different set of objects and join them in your query, you have to be very careful. Especially when one of the sources is live webservice. Then the join will every time go to the WebService and create the IEnumerable<T> (the out put).


    Ø       While working with Linq to SQL, there are very few areas where you can fine tune the query. Rather you might be very comfortable writing super fast queries in SQL. You have no idea how Linq to SQL will create the SQL queries which will be sent to SQL Server. But you can check the outgoing SQL queries through DataContext class or Orcas debugger. I would suggest you to use stored procedure to make sure your query is super fast and well executed.


    Ø       Sometimes differed loading is not the accepted behavior. As it executes the query multiple times (per master data). Let’s say the scenario of Customer an Order where each customer has multiple orders. If you run a nested for loop for each customer then the query will be created and executed every time. So we have to be very careful again here if we want to avoid the differed loading by using the DataShape class.



  • Wriju's BLOG

    SQL Server 2008 (Katmai) I am proud user


    Yes, I have installed SQL Server 2008 (aka Katmai) Dev Edn. Few things for successful installation,

    • Better use newly formatted machine
    • Make sure that you have IIS installed (otherwise it will fail to install Reporting Service)

    Everything works perfectly fine.


  • Wriju's BLOG

    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.




  • Wriju's BLOG

    Visual Studio Orcas Samples


    C# LINQ Samples and content for Beta 1

    VB LINQ Samples for Beta 1


  • Wriju's BLOG

    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 SqlMembershipProvider and the security Web controls.
  • Part 2 - master how to create roles and assign users to roles. This article shows how to setup roles, using role-based authorization, and displaying output on a page depending upon the visitor's roles.
  • Part 3 - see how to add the membership-related schemas to an existing database using the ASP.NET SQL Server Registration Tool (aspnet_regsql.exe).
  • Part 4 - improve the login experience by showing more informative messages for users who log on with invalid credentials; also, see how to keep a log of invalid login attempts.
  • Part 5 - learn how to customize the Login control. Adjust its appearance using properties and templates; customize the authentication logic to include a CAPTCHA.
  • Part 6 - capture additional user-specific information using the Profile system. Learn about the built-in SqlProfileProvider.
  • Part 7 - the Membership, Roles, and Profile systems are all build using the provider model, which allows for their implementations to be highly customized. Learn how to create a custom Profile provider that persists user-specific settings to XML files.
  • Part 8 - learn how to use the Microsoft Access-based providers for the Membership, Roles, and Profile systems. With these providers, you can use an Access database instead of SQL Server.
  • Namoskar!!!

  • Wriju's BLOG

    Linq to SQL: Writing clean code


    As you know with Orcas Beta 1 we have Linq to SQL template available. There we can drag and drop any database table and the code will be ready for you to use. What if you are not a wizard addicted like me and wants to write your own clean code?


    I love the conciseness of the C# 3.0 and the lesser code strategy. Let’s try to write some clean code which will allow us to use the relationship also. I will use Northwind and will use Products and Category table. But I am interested in only few selected columns














    I will write my own Linq to SQL code and use my own mapping. You always need to use two major namespaces


    using System.Data.Linq;

    using System.Data.Linq.Mapping;


    I will create a mappings between my class property and SQL columns. For that I need to use couple of attributes. Let’s try that out


    #region Products Class


    public class Products



        public int ProductId{get;set;}



        public string ProductName { get; set; }



        public int CategoryID { get; set; }



        public decimal UnitPrice { get; set; }




    #region Categories Class

    [Table(Name = "Categories")]

    public class Categories


        [Column(IsPrimaryKey = true)]

        public int CategoryID { get; set; }



        public string CategoryName { get; set; }





    Now I am ready to go.


    Let’s suppose I have one console application, so the code will look like,


    static void Main(string[] args)


        DataContext db = new DataContext

    (@"Data Source=BLR2B03-A\SQLEXPRESS;Initial Catalog=Northwind;");


        var products = db.GetTable<Products>();

        var categories = db.GetTable<Categories>();


        var q = from p in products

                join c in categories

      on p.CategoryID equals c.CategoryID                   

                select new { p.ProductName, c.CategoryName };






    That’s all. Isn’t it much cleaner code? Happy weekend.



  • Wriju's BLOG

    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.


  • Wriju's BLOG

    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, it is type safe. Because of this it also reduces unnecessary Boxing and Unboxing which can be memory intensive. Another thing is that because of snippet feature just by typing ~ we can put destructor in our class and if there is nothing in the body of destructor, the natural life cycle of garbage collector may get hampered.

    Such tips and tricks are available in MSDN

  • Writing Faster Managed Code: Know What Things Cost

  • Writing High-Performance Managed Applications : A Primer

  • Garbage Collector Basics and Performance Hints

  • Performance Tips and Tricks in .NET Applications

  • Hope this will be helpful.


  • Wriju's BLOG

    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 data service happens in terms of HTTP verbs such as GET, POST, PUT and DELETE, and the data exchanged in those interactions is represented in simple formats such as XML and JSON. As mentioned in ADO.NET Team's BLOG. You can also visit the entry by Pablo Castro.

    Documentation is available for download,

    Microsoft Project Codename "Astoria" Overview Document

    Microsoft Project Codename "Astoria" - Documentation

    Check out the Astoria at http://astoria.mslivelabs.com


  • Wriju's BLOG



    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



  • Wriju's BLOG

    ADO.NET Entity Framework Update


    Microsoft decided to launch ADO.NET Entity Framework and Tools during the first half of 2008 as an update to the Orcas release of the .NET Framework and Visual Studio.

    For more in details please refer

    ADO.NET Entity Framework Update

    Microsoft’s Data Access Strategy


  • Wriju's BLOG

    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).


    Recommended session,

    DEV04 - Using LINQ to Dramatically Improve Data Driven Development in Web Applications by Anders Hejlsberg



  • Wriju's BLOG

    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 available for wizard. Let us see how we can leverage that,


    Create a Windows Application using Orcas Beta 1.  Then from the Solution Explorer add “ADO.NET Entity Data Model”.


    Then choose the option “Generate From database”.



    Then point to the database you are targeting.



    Then choose the Tables  


    Now add GridView and a Button (to load the data from database). Add the following code in your ButtonClick event. You have to use using NorthwindModel;


    private void button1_Click(object sender, EventArgs e)


        NorthwindEntities db = new NorthwindEntities();


        var q = from c in db.Customers

                select c;


        dataGridView1.DataSource = q.ToList();



    Now you run the apps to see the output.


    Let me explain you what it is. It creates couple of files when you use wizard for Entity. In the file Model1.cs it creates a context class with the name NorthwindEntities and we have to initialize this class with the connection string. By default it takes the connection string located in Apps.config (which gets there while choosing the database).


    You can add search queries like,


    var q = from c in db.Customers

            where c.City == txtCity.Text

            select c;


    In txtCity you can pass dynamic input at runtime.


    Hope you have enjoyed this.




  • Wriju's BLOG

    Windows Live Writer (Beta) : Using Amazing Tool for blogging


    I though that I must dedicate my first blog entry which I have used for this blog. You can get this from http://get.live.com/betas/writer_betas and enjoy the power.



  • Wriju's BLOG

    Orcas Beta 1: When ADO.NET EDM Wizard is not working


    You might face the same issue as I faced today. I was trying to generate an Entity Data Model using the wizard and the code file was almost empty. So I was not able to implement that model to display the records.


    This is a known issue and the fix is available at Microsoft. Please go ahead and download the fix from http://www.microsoft.com/downloads/details.aspx?FamilyID=f69e9eb8-0ebd-4fba-a4cc-2050297ba75b&DisplayLang=en and enjoy the feature.



  • Wriju's BLOG

    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


      Separates object construction from its representation

      Factory Method

      Creates an instance of several derived classes


      A fully initialized instance to be copied or cloned


      A class of which only a single instance can exist


      Structural Patterns


      Match interfaces of different classes


      Separates an object’s interface from its implementation


      A tree structure of simple and composite objects


      Add responsibilities to objects dynamically


      A single class that represents an entire subsystem


      A fine-grained instance used for efficient sharing


      An object representing another object


      Behavioral Patterns

      Chain of Resp.

      A way of passing a request between a chain of objects


      Encapsulate a command request as an object


      A way to include language elements in a program


      Sequentially access the elements of a collection


      Defines simplified communication between classes


      Capture and restore an object's internal state


      A way of notifying change to a number of classes


      Alter an object's behavior when its state changes


      Encapsulates an algorithm inside a class

      Template Method

      Defer the exact steps of an algorithm to a subclass


      Defines a new operation to a class without change




  • Wriju's BLOG

    Cω Overview


    Do you know there is another language called ? 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 game for highly efficient group of people who develop OS or Database.


    For more visit http://research.microsoft.com/Comega/doc/comega_whatis.htm



  • Wriju's BLOG

    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 



  • Wriju's BLOG

    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 code like


    Func<int, int> f = x => x * 5;



    and you execute it. This will execute normally.


    But what if you want to store the whole function body in IL and compile as and when required. Then the above code look little different.


    Expression<Func<int, int>> e = x => x * 5;


    Now you cannot execute expression like function. But you can see the body of the expression in Expression Tree Visualizer. To use Expression you need to use the namespace System.Linq.Expressions


    So if you use the code like




    The output will look like, x => (x * 5) instead of some kind of perfect integer values. Now if you want to use the function written there in Expression Tree you need little different approach,


    var f = e.Compile();



    Compile statement will compile the IL code and your function will be ready for execution.


    If you want to write your own Expression instead of using the Expression <> to convert the delegate to function call, .NET allows us to do that. The Expression representation of the above f = x => x * 5; will look like


    ParameterExpression x = Expression.Parameter(typeof(int), "x");

    Expression body = Expression.Multiply(x, Expression.Constant(5));

    Expression<Func<int, int>> e = Expression.Lambda<Func<int, int>>(body, x);




    This happens exactly when you use SQL statement and execute it SQL Server database. Internally it creates functions and send to the compiler, then compiler compiles the code during the execution. Various rules engine like BizTalk uses this concept.


    Now if you put a break point on e and hover over it during debug you can get the Expression Tree out of it.



    I am loving itJ





  • Wriju's BLOG

    Visual Studio Codename Orcas Beta Documentation


    Find MSDN documentation for more information.

    Visual Studio
    Visual Studio Team System


    Thanks and enjoy.



  • Wriju's BLOG

    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 writing your own admin tool.

    You need to have using System.Diagnostics on top of your page.


    In Orcas Beta 1 code looks like,


    var ProcessQuery = from p in Process.GetProcesses()

                       orderby p.PagedMemorySize64 descending

                       select new {

    Name = p.ProcessName,

    Size = p.PagedMemorySize64



    foreach (var aa in ProcessQuery)


        Console.WriteLine(" [ " + aa.Size + " ] " + aa.Name);



    I love LINQ. It is ……….


    And the output is….


     [ 62271488 ] devenv

     [ 40300544 ] sqlservr

     [ 39219200 ] svchost

     [ 28323840 ] CSharp3_23Apr.vshost

     [ 16941056 ] CcmExec

     [ 16150528 ] InoTask

     [ 15310848 ] winlogon

     [ 15220736 ] InoRT

     [ 9261056 ] explorer

     [ 8540160 ] lsass

     [ 6107136 ] inetinfo

     [ 4919296 ] InoRpc

     [ 4702208 ] services

     [ 4599808 ] spoolsv

     [ 4210688 ] wmiprvse

     [ 3592192 ] svchost

     [ 3072000 ] svchost

     [ 3031040 ] winlogon

     [ 2322432 ] svchost

     [ 2064384 ] wmiprvse

     [ 1810432 ] csrss

     [ 1572864 ] GrooveMonitor

     [ 1568768 ] svchost

     [ 1531904 ] wdfmgr

     [ 1486848 ] rdpclip

     [ 1441792 ] igfxtray

     [ 1355776 ] alg

     [ 1142784 ] FwcAgent

     [ 1081344 ] FwcMgmt

     [ 942080 ] sqlbrowser

     [ 933888 ] sqlwriter

     [ 929792 ] ctfmon

     [ 741376 ] csrss

     [ 385024 ] logon.scr

     [ 155648 ] smss

     [ 0 ] System

     [ 0 ] Idle





  • Wriju's BLOG

    Visual Studio Code Name “Orcas” Beta 1 Released


    Go ahead and download from here.



  • Wriju's BLOG

    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


    Couple of the examples are given there


    x => x + 1                // Implicitly typed, expression body

    x => { return x + 1; }    // Implicitly typed, statement body

    (int x) => x + 1                // Explicitly typed, expression body

    (int x) => { return x + 1;}// Explicitly typed, statement body

    (x, y) => x * y            // Multiple parameters

    () => Console.WriteLine()  // No parameters


    It is very interesting to me. Hope you will also enjoy this.



  • Wriju's BLOG

    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 sure that you are very excited.


    //Array of string initialization

    string[] sTest = new string[]

    { "Wriju", "Writam", "Deb", "Sumitra" };


    //Dictionary object initialization

    Dictionary<int, string> objDic =

    new Dictionary<int, string>

    { { 0, "Zero" }, { 1, "One" } };


    //Generic Initialization

    List<Cust> objCusts = new List<Cust>{

    new Cust{ID=1, Name="Wriju"},

         new Cust{ID=2, Name="Writam"},

         new Cust{ID=3, Name="Deb"},

         new Cust{ID=4, Name="Sumitra"}};



  • Wriju's BLOG

    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 has to be the first part of the first argument of that method


    This helps us to extend methods for the types that are already part of .NET Framework.


    If you have declared an Extension Method like


    public static void Foo(this string sVal)


        //Do something



    If you make a call to this method the syntax will look like,


    string s = "Something for test";



    The actual call will happen like

    myExtensions.Foo(s); Here myExtensions is the static class under which you have defined the Foo method.


    Another first class treatment of static method in .NET. It allows us to feel the magic as if we are writing CLR code. You can define most of your utility functions in form of extension method and by using the “using” block you can use them in your code behind file.



    The real life example of the extension method may look like,


    public static class myExtensions


        public static string GetString(this string[] arrStr)


            StringBuilder sb = new StringBuilder();


            foreach (string s in arrStr)


                if (sb.Length != 0)





            return sb.ToString();





    class Program


        static void Main(string[] args)


            string[] sTest = new string[]

    { "Wriju", "Writam", "Deb", "Sumitra" };









  • Page 23 of 26 (626 items) «2122232425»