• Wriju's BLOG

    Free EBooks at CodePlex

    • 9 Comments

    There are many more books available. Go and grab them

     

    ·         Acceptance Test Engineering Guidance

    ·         Application Architecture Guidance

    ·         Common Service Locator

    ·         Composite Application Guidance for WPF

    ·         Design for Operations

    ·         Enterprise Library

    ·         ESB Guidance

    ·         GAX Extensions Library

    ·         Guidance Explorer

    ·         Performance Testing Guidance for Web Applications

    ·         Performance Testing Guidance Project

    ·         SharePoint Development Guidance

    ·         Smart Client Guidance

    ·         Team Development with Visual Studio Team Foundation Server

    ·         Unity Application Block

    ·         VSTS Guidance Project

    ·         WCF Security Guidance

    ·         Web Client Software Factory

    ·         Web Service Software Factory

     

    More http://msdn.microsoft.com/hi-in/practices/bb190344(en-us).aspx 

    Namoskar!!!

  • Wriju's BLOG

    C# and VB.NET Coding Standards

    • 0 Comments

    This one is small and concise. I love the work on standards. You may or may not agree to it. But take a look here and download the pages,

     

    Check here

     

    This work is from Clint Edmonson, Architect Evangelist for Microsoft.

     

    Namoskar!!!

  • Wriju's BLOG

    Free EBooks on Architecture

    • 0 Comments

    Dear all,

    This indeed a good news for us, there has been many freely available guides. Why you should be paying others? Get the copy now for free

    Namoskar!!!

  • Wriju's BLOG

    Choosing between LINQ to SQL and Entity Framework

    • 6 Comments

    There have been many talks going on while deciding between LINQ to SQL and Entity Framework.

     

    There is one article published in MSDN at

     

    When do I use LINQ to SQL?

     

    I want to

    LINQ to SQL is applicable

    Use an ORM solution and my database is 1:1 with my object model

    Use an ORM solution with inheritance hierarchies that are stored in a single table

    Use my own plain CLR classes instead of using generated classes or deriving from a base class or implementing an interface

    Leverage LINQ as the way I write queries

    Use an ORM but I want something that is very performant and where I can optimize performance through stored procedures and compiled queries

     

    When to use LINQ to Entity?

     

    I want to

    LINQ to Entities is applicable

    Write applications that can target different database engines in addition to Microsoft SQL Server

    Define domain models for my application and use these as the basis for my persistence layer.

    Use an ORM solution where my classes may be 1:1 with the database or may have a very different structure from the database schema

    Use an ORM solution with inheritance hierarchies that may have alternative storage schemes (single table for the hierarchy, single table for each class, single table for all data related to specific type)

    Leverage LINQ as the way I write queries and have the query work in a database vendor agnostic manner.

    Use an ORM but I want something that is very performant and where I can optimize performance through stored procedures and compiled queries

     

    For more you must visit Introducing LINQ to Relational Data at MSDN.

     

    Namoskar!!!

  • Wriju's BLOG

    ADO.NET Entity Framework : Learn EntitySQL

    • 2 Comments

    I am pretty sure that many of you do not want to learn EntitySQL J. But for those who would may follow the below links

     

    Entity SQL Overview

    An overview of Entity SQL.

     

    Entity SQL Reference

    Provides syntax for the Entity SQL functions and operators.

     

    Namoskar!!!

  • Wriju's BLOG

    LINQ to Entity : Supported and Unsupported Methods

    • 5 Comments

    There is a correction for this Post, so do I have changed the title. Thanks to Chris Love who pointed me the faults with earlier post,

    I got few question on some of the popular paging methods of LINQ which does not work on LINQ to Entity. This is by design and quite logical. In LINQ to SQL scenario they do translate to native TSQL and uses some of its properties and functions. Thus this cannot be made generic for other databases like Oracle/DB2.

     

    There is a list published in MSDN with the operators at,

     

    Projection and Restriction Methods (LINQ to Entities)

    Lists the supported and unsupported projection and restriction methods.

     

    Join Methods (LINQ to Entities)

    Lists the supported and unsupported joining methods.

     

    Set Methods (LINQ to Entities)

    Lists the supported and unsupported set methods.

     

    Ordering Methods (LINQ to Entities)

    Lists the supported and unsupported ordering methods.

     

    Grouping Methods (LINQ to Entities)

    Lists the supported and unsupported grouping methods.

     

    Aggregate Methods (LINQ to Entities)

    Lists the supported and unsupported aggregating methods.

     

    Type Methods (LINQ to Entities)

    Lists the supported and unsupported type methods.

     

    Paging Methods (LINQ to Entities)

    Lists the supported and unsupported paging methods.

     

     

    Namoskar!!!

  • Wriju's BLOG

    Visual Studio Gallery

    • 1 Comments

    A single place to get the the tools you might need during your development with Visual Studio.

    http://visualstudiogallery.com/

    Happy new year 2009.

    Namoskar!!!

  • Wriju's BLOG

    Application Architecture Guide 2.0 Released – Free E-Book Download

    • 1 Comments

    Happy news for all the developers around the world, we have released the Patterns and Practices guidance on Application Architecture. It is 381 paged PDF book and freely available from http://www.codeplex.com/AppArchGuide.

    This books is majorly divided into four parts,

    Part I, Fundamentals
    Part II, Design
    Part III, Layers
    Part IV, Archetypes

    and forwarded by S. Somasegar and Scott Guthrie. So enjoy.

    Namoskar!!!

  • Wriju's BLOG

    Windows Live Photo Gallery : Easily Stitch Panoramic Photos

    • 2 Comments

    I am visually challenged nor a good photographer. Recently I have been to the foot hills of Eastern Himalayan range (http://en.wikipedia.org/wiki/Buxa_Tiger_Reserve). I and Tupur been to the dry river bed of Jayanti, took some series of photos. I had plan to stitch them.

    Wonder!!! Live Photo Gallery already has this feature. Bingo!!! I created one.

    Tutorial video is available at MSN Video.

    And the result is,

    JayantiRange

    Namoskar!!!

  • Wriju's BLOG

    www.pinvoke.net a site for use

    • 1 Comments

    http://www.pinvoke.net/default.aspx is a must to have site if you are a frequent user of Windows API and need to create a call for them.

    Namoskar!!!

  • Wriju's BLOG

    What is Cloud Platform

    • 1 Comments

    Read it (why should you waste time on my BLOGJ)

    http://www.davidchappell.com/CloudPlatforms--Chappell.pdf

     

    Namoskar!!!

  • Wriju's BLOG

    CodeRush Xpress an amazing tool to work with Visual Studio 2008

    • 2 Comments

    Today I have came across a tool called CodeRush Xpress, a free AddIn which can be integrated with Visual Studio and make fun of the coding. This is a combined effort which DevExpress have had with Microsoft by leveraging the existing Visual Studio 2008 IDE.

    One scenario is very common to all of us when we need to expose the anonymous type outside the method. Then we need to take the pain of declaring the whole class and use instead of anonymous type. Else there are some type cast way of doing it.

    CodeRush made this easy for us, and now we can create class out of any anonymous type per say.

    Let’s say you have the line,

    var obj = new { Id = 1, Name = "Wriju" };

    Install CodeRush and  put your cursor at “new”, click Ctrl+~ (tilde button above Tab). This will create a whole class for you like,

    [DebuggerDisplay("\\{ Id = {Id}, Name = {Name} \\}")]

    private sealed class MyClass : IEquatable<MyClass>

    {

        private readonly int _Id;

        private readonly string _Name;

     

        public MyClass(int id, string name)

        {

            _Id = id;

            _Name = name;

        }

     

        public override bool Equals(object obj)

        {

            if (obj is MyClass)

                return Equals((MyClass)obj);

            return false;

        }

        public bool Equals(MyClass obj)

        {

            if (!EqualityComparer<int>.Default.Equals(_Id, obj._Id))

                return false;

            if (!EqualityComparer<string>.Default.Equals(_Name, obj._Name))

                return false;

            return true;

        }

        public override int GetHashCode()

        {

            int hash = 0;

            hash ^= EqualityComparer<int>.Default.GetHashCode(_Id);

            hash ^= EqualityComparer<string>.Default.GetHashCode(_Name);

            return hash;

        }

        public override string ToString()

        {

            return String.Format("{{ Id = {0}, Name = {1} }}", _Id, _Name);

        }

     

        public int Id

        {

            get

            {

                return _Id;

            }

        }

        public string Name

        {

            get

            {

                return _Name;

            }

        }

    }

    There are many more and I will let them published in my blog. But this is a great tool for developers who live their life with VS source code.

    Namoskar!!!

  • Wriju's BLOG

    Visual Studio 2010: First Look of my VS 2010

    • 3 Comments

    How this new Visual Studio 2010 looks like? This has three views. Here it is,

    Start Page > Welcome

    image

    Start Page > Projects

    image

    Start Page > Visual Studio

    image

    Namoskar!!!

  • Wriju's BLOG

    C# 4.0: My First Dynamic Program

    • 2 Comments

    I am super excited to see Anders demonstrating C# 4.0 for first time in public. I am a real fan of him and downloaded the public bit to tryout. Here is my first Dynamic C# 4.0 program.

     

    There is nothing much to be excited from my Program but I am very much after hitting F5.

     

    static void Main(string[] args)

    {

        dynamic i = 10;

        dynamic sHello = "Hello C# 4.0";

     

        Console.WriteLine(i);

        Console.WriteLine(sHello);

    }

     

    More to come.

     

    Namoskar!!!

  • Wriju's BLOG

    PDC 2008 Must be Enjoyed

    • 1 Comments

    If you are thinking that you are a looser not by attending PDC 2008, forget it. Stretch your body as you might to stay connected to your chair for long time.

    What is

    • Visual Studio 2010
    • Windows Azure
    • Project "Velocity"
    • Dublin
    • Oslo
    • Parallelism
    • S+S

    and many more.. So without wasting time join and view the video, download them.

    https://sessions.microsoftpdc.com/

    https://sessions.microsoftpdc.com/public/timeline.aspx

    image

    Namoskar!!!

  • Wriju's BLOG

    Application Architecture Guide 2.0 EBook

    • 4 Comments

    For you to design the better future.

    image

    Link to download http://www.codeplex.com/AppArchGuide 

    Namoskar!!!

  • Wriju's BLOG

    ADO.NET Entity: LINQ to Entity with Relationship

    • 4 Comments

    Relationship and getting data from Entity Framework using Northwind database

    image

    Simple Query

     

    using (NorthwindEntities ctx = new NorthwindEntities())

    {

        var query = from o in ctx.Orders

                    select o.OrderID;

     

        foreach (var k in query)

        {

            Console.WriteLine(k);

        }

    }

     

    Now if you want to filter this with the parent information,

     

    var query = from o in ctx.Orders

                where o.Customers.City == "London"

                select o.OrderID;

    This actually goes one level up and then filters the data.

     

    Include Child Information

     

    var query = from c in ctx.Customers

                where c.City == "London"

                select c;

     

    foreach (var k in query)

    {

    Console.WriteLine(k.ContactName);

    }

     

    Now if you want to get the “Orders” table, there are two ways to do it,

     

    Immediate Loading

     

    var query = from c in ctx.Customers.Include("Orders")

                where c.City == "London"

                select c;

     

    foreach (var k in query)

    {

        Console.WriteLine(k.Orders.Count);

    }

     

    On-Demand Loading

     

    var query = from c in ctx.Customers

                where c.City == "London"

                select c;

     

    foreach (var k in query)

    {

        //if not loaded then load it

        if (!k.Orders.IsLoaded)

            k.Orders.Load();

     

        Console.WriteLine(k.Orders.Count);

    }

     

     

    Namoskar!!!

     

  • Wriju's BLOG

    MSDN Magazine Online

    • 1 Comments

    Get your MSDN magazine from web at http://msdn.microsoft.com/msdnmag/.

    Namoskar!!!

  • Wriju's BLOG

    ADO.NET Entity: Insert Update and Delete with Relationship

    • 18 Comments

    Few days back I had written an article on Insert/Update/Delete for simple standalone tables at ADO.NET Entity: Insert Update and Delete. Now after that many of you had requested me to put article on how it works with relationship.

     

    Here I will use a database created by me. There will be two tables connected with each other.

    image

    Now I will create TestDB.edmx out of this database.

     

    image 

    Insert

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Create new Department

        Dept d = new Dept() { DeptName = "ADO Entity" };

     

        //Create new Employee 1

        EmpDept ed1 = new EmpDept() { EmpName = "ADO Employee 1" };

     

        //Create new Employee 2

        EmpDept ed2 = new EmpDept() { EmpName = "ADO Employee 2" };

     

        //Add employee to the Dept *OBJECT*

        d.EmpDept.Add(ed1);

        d.EmpDept.Add(ed2);

     

        //Updating the context

        ctx.AddToDept(d);

     

        //Save to Database

        ctx.SaveChanges();

    }

     

    Update

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Get an existing Department

        Dept dep = (from d in ctx.Dept

                    where d.DeptId == 22

                    select d).First();

     

        //Set new Department name

        dep.DeptName = "ADO.NET 3.0";

     

        //Create new Employee 2

        EmpDept ed2 = new EmpDept() { EmpName = "ADO 2" };

     

        //Add *new* employee to the Dept *OBJECT*

        dep.EmpDept.Add(ed2);

     

        //Save to Database

        ctx.SaveChanges();

    }

     

    Delete

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Get an existing Department

        Dept dep = (from d in ctx.Dept.Include("EmpDept")

                    where d.DeptId == 22

                    select d).First();

     

        /*

         Needd to do ToList() becuase once you delete

         a record then iteration will not be possible.         

        */

        foreach (EmpDept ed in dep.EmpDept.ToList())

        {

            //This removes relationship from Context

            dep.EmpDept.Remove(ed);

     

            //Delete it from context

            ctx.DeleteObject(ed);       

        }

     

        //Delete the master table

        ctx.DeleteObject(dep);

           

        //Save to Database

        ctx.SaveChanges();

    }

     

    Note: during delete you first need to remove the relationship from entity and then delete the object from entity. So you need to keep the child data offline and then do operation. Then delete the main object.

     

    In my next post I will write about “how to select with Relationship”.

     

    Namoskar!!!

     

  • Wriju's BLOG

    Visual Studio 2010 and .NET Framework 4.0 Overview

    • 0 Comments

    Know more about it and keep you sink with http://msdn.microsoft.com/en-us/vstudio/products/cc948977.aspx

    What's New

    Additional Resources

    Namoskar!!!

  • Wriju's BLOG

    ADO.NET Entity: Insert Update and Delete

    • 29 Comments

    For small blogs, it requires more references and explanation, which sometimes are redundant. So I thought of writing single blog which is combination of topics more or less related to one thing.

     

    I am exploring ADO.NET Entity Framework and have been trying things out there. Here I am planning to demonstrate how to do insert, update and delete.

     

    Here I will use a database created by me. In the Emp table there are two columns Id (Primary and auto-generated) and Name (simple varchar(50)).

    image

    Now I will create TestDB.edmx out of this database.

    image

    Insert

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Create new Emp object

        Emp e = new Emp() { Name = "Test Employee" };

     

        //Add to memory

        ctx.AddToEmp(e);

     

        //Save to database

        ctx.SaveChanges();

    }

     

     

    Update

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Get the specific employee from Database

        Emp e = (from e1 in ctx.Emp

                 where e1.Name == "Test Employee"

                 select e1).First();

     

        //Change the Employee Name in memory

        e.Name = "Changed Name";

     

        //Save to database

        ctx.SaveChanges();

    }

     

    Delete

     

    using (TestDBEntities ctx = new TestDBEntities())

    {

        //Get the specific employee from Database

        Emp e = (from e1 in ctx.Emp

                 where e1.Name == "Test Employee"

                 select e1).First();

     

        //Delete it from memory

        ctx.DeleteObject(e);

     

        //Save to database

        ctx.SaveChanges();

    }

     

    In my next post I will write about “how to handle CRUD with Relationship”.

    Namoskar!!!

  • Wriju's BLOG

    Microsoft Project Code Named “Velocity”

    • 1 Comments

    "Velocity" is a distributed in-memory application cache platform for developing scalable, high-performance applications. "Velocity" can be used to cache any CLR object and provides access through simple APIs. The primary goals for "Velocity" are performance, scalability and availability.

    http://msdn.microsoft.com/en-us/data/cc655792.aspx

    Technical Articles

    Blog

    Microsoft Project Code Named "Velocity" Team Blog

    Forum

    Microsoft Project Code Named “Velocity”

    Download

    Microsoft Project Code Named “Velocity”

    Samples

    Microsoft Project Code Named “Velocity” on Code Gallery

    Namoskar!!!

  • Wriju's BLOG

    Windows Forms – Enable Shortcut Key all over the Form

    • 10 Comments

    Windows Application and shortcut key are synonyms. People prefer to use shortcut keys for faster activity. Assume you are in a text box and you want to hit F5 to reload the form. You do not want to move your mouse cursor. So what you will be doing is that you will be adding “Key Down” event to the text box. But if you are in a different text box or in a button that will not work. So you will add “Key Down” event to your form.

     

    But you need to enable a property to work it properly and that’s the trick.

     

    private void Form1_KeyDown(object sender, KeyEventArgs e)

    {

        if (e.KeyCode == Keys.F5)

        {

            btnRefresh_Click(null, null);

        }

    }

     

    But golden trick is, in the property window of the Form make the following changes

     

    KeyPreview = True 

    Enjoy programming. 

    Namoskar!!!

  • Wriju's BLOG

    Programmatically invoking the Live.com search

    • 0 Comments

    Live.com you need to automate that in your Windows application. You will use the WebBrowser control. This is a very powerful control and allows us to control things through DOM. Here is a small code which insert values to the live.com’s seach text box and clicks the “Go” button. I have created a windows forms application and added a WebBrowser control named “webBrowser1”.

     

    //Set the value to the Search text box

    webBrowser1.Document.GetElementById("sb_form_q").SetAttribute("value", "Wriju's BLOG");

     

    //Now click the button

    //this actually submits the one and only one form

    //So you need to do that

    webBrowser1.Document.Forms[0].InvokeMember("submit");

     

    Namoskar!!!

  • Wriju's BLOG

    LINQ to SQL vs. ADO.NET – A Comparison

    • 17 Comments

    ADO.NET is our contemporary data access component and now we have written many applications. Now there has been a lot of talk on LINQ to SQL. So we are little skeptical about this component and trying to find some relation between existing ADO.NET technology.

     

    Purpose of this post is to give some quick brief on some major differences between ADO.Net and LINQ to SQL. I have not used 100% code as this is just to give an idea. The database I have used here is Northwind (SQL Server 2000 Sample database).

     

    Some comparison,

     

    Scenario 1

    +++++++

    Establishing connection between database and application,

     

    ADO.NET

    using(SqlConnection conn = new SqlConnection("Connection String"))

    {

        conn.Open();

    }

     

    LINQ to SQL

    You create a .dbml file and give a name (assume “NW.dml”). Then there will be a DataContext class created. So you need to initialize the instance of an object.

     

    NWDataContext db = new NWDataContext("Connection String");

     

    You do not need to call any Open() method. Datacontext handles well the open and close method.

     

    Scenario 2

    +++++++

    Getting data from database,

     

    ADO.NET

    using(SqlConnection conn = new SqlConnection("Connection String"))

    {

        using (SqlCommand comm = new SqlCommand("Select * from Customers"))

        {

            conn.Open();

            SqlDataReader reader = comm.ExecuteReader();

            DataTable dt = new DataTable("New Table");

            dt.Load(reader);

        }

    }

     

    LINQ to SQL

    using (NorthwindDataContext db = new NorthwindDataContext())

    {

        //You can also use "var" at "IEnumerable<Customer>"

        IEnumerable<Customer> custs = from c in db.Customers

                                      select c;

     

        foreach (Customer c in custs)

        {

            Console.WriteLine(c.CompanyName);

        }

    }

     

    WOW!!! I have received comment from our Senior Program Manager Dinesh Kulkarni from LINQ to SQL team when I requested him to visit my blog. He mentioned,

    DataTable provides you a cache that can be re-enumerated without DB roundtrip while LINQ to SQL results need to be explicitly cached with something like a ToList()/ToArray(). Identity caching in DataContext aside, the L2S code is closer to enumerating a DataReader. Although DataReader does not allow you to re-enumerate and requires another ExecuteReader, the impact of reenumerating L2S query is the same – another roundtrip to DB.

    Scenario 3

    +++++++

    Inserting into the database,

     

    ADO.NET

     

    using(SqlConnection conn = new SqlConnection())

    {

        conn.Open();  

        SqlCommand comm = new SqlCommand("INSERT INTO...", conn);

     

        comm.ExecuteNonQuery();

    }

     

    LINQ to SQL

     

    using (NorthwindDataContext db = new NorthwindDataContext())

    {

        //Create a new object

        Customer c = new Customer();

        c.CustomerID = "ABCDE";

        //.... add all the properties you need to add while inserting

     

        //Add it to the collection

        db.Customers.InsertOnSubmit(c);

     

        //Save the changes to the database

        db.SubmitChanges();   

    }

     

    Scenario 4

    +++++++

    Updating database,

    ADO.NET

     

    Same as Scenario 3

     

    LINQ to SQL

    using (NorthwindDataContext db = new NorthwindDataContext())

    {

        //Get the object from database

        Customer cust = (from c in db.Customers where c.CustomerID == "ALFKI" select c).First();

     

        //Update the exsisting value

        cust.CompanyName = "I do not know?";   

       

           

        //Save the changes to the database

        db.SubmitChanges();   

    }

     

    Scenario 5

    +++++++

    Deleting records from the database,

    ADO.NET

     

    Same as Scenario 3

     

    LINQ to SQL

    using (NorthwindDataContext db = new NorthwindDataContext())

    {

        //Get the object from database

        Customer cust = (from c in db.Customers where c.CustomerID == "ALFKI" select c).First();

     

        //Remove it from collection

        db.Customers.DeleteOnSubmit(cust);

           

        //Save the changes to the database

        db.SubmitChanges();   

    }

     

    Scenario 5

    +++++++

    Executing stored proc which returns record(s),

     

    ADO.NET

    using(SqlConnection conn = new SqlConnection())

    {

        conn.Open();

        using (SqlCommand comm = new SqlCommand("SalesByCategory", conn))

        {

            comm.CommandType = CommandType.StoredProcedure;

            comm.Parameters.AddWithValue("@param1", "value1");

            comm.Parameters.AddWithValue("@param2", "value2");

     

            SqlDataReader reader = comm.ExecuteReader();       

        }

    }

     

    LINQ to SQL

    In LINQ to SQL it becomes metod as you drag and drop it to .dbml file,

     

    using (NorthwindDataContext db = new NorthwindDataContext())

    {

     

        var outPut = db.SalesByCategory("SeaFood", "1998");        

    }

     

    Performance of LINQ to SQL and ADO.NET

     

    LINQ to SQL Performance Part 1

    LINQ to SQL Performance Part 2

    LINQ to SQL Performance Part 3

    LINQ to SQL Performance Part 4

    LINQ to SQL Performance Part 5

     

    There are a many to discuss. Hope you have enjoyed it.

     

     

    Namoskar!!!

Page 17 of 26 (626 items) «1516171819»