• 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

    • 27 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!!!

  • Wriju's BLOG

    Celebrating 200th MSDN Blog Post

    • 0 Comments

    Wow experience!!! 200+ posts on MSDN with millions of hits it’s a great pleasure being at Microsoft with additional takeaways. I never thought in my life that I would be blogging. I had a dream that one day I will become writer (was not sure on what though). Blogging is a great tool to give values back to community for people with less power (like me or introvert).

    My journey has been always a pleasure (be it blogging or 5 day long on-road cross country cargo truck travel). But my greatest takeaway was when my blog was in MSDN C# Home page. Charlie was kind enough to put my blog in the same list with Scott Guthrie (http://weblogs.asp.net/scottgu/). I never had a clue on how Scott manages to write blog so regularly.

    You may find some of my selected and relevant past posts are at Charlie’s blog at Community Convergence and my journey stared from Community Convergence XXXV. I have no words to say thanks to Charlie (our very own C# Community Program Manager).  Many people have encouraged me in many ways, Program managers, friends, Microsoft Partners (with whom I work professionally), my super technical Microsoft teammates, people from everywhere over the web. Some of them have added my blog to their favorite list (priceless to me always).

    There are many things I have planned to write. I am a lazy person, so I need to be focused and keep on contributing to my blog.

    But I have promises to keep,

    And miles to go before I sleep,

    And miles to go before I sleep.

     

    I am not a good writer, but I love many things at Microsoft.

     

    Namoskar!!!

  • Wriju's BLOG

    How to copy my snippet in Visual Studio 2008

    • 2 Comments

    I use Visual Studio 2008 code snippet a lot when I write code for my presentation. It saves a lot of time and it is very elegant. But I used to struggle a lot while changing my demo machine. Because I had to repeat the same process again and again from Tools > Snippet Manager, I find it very inconvenient if you have many snippets.

    There is an elegant way to do that, under

    C:\Documents and Settings\<<logged in user>>\My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets  

    Copy the files from your source machine and paste them to the destination machine’s same folder. You will get all the snippets. You do not have to use Snippet Manager anymore to upload snippet.

    Namoskar!!!

  • Wriju's BLOG

    ZoomIt : Fantastic Windows Zooming Application

    • 1 Comments

    When I show demo using my desktop I often come across to the scenarios where things are very small. I was using Windows Magnifier. I found this tool later and this is very helpful. This tool was created by Microsoft Technical Fellow, Mark Russinovich.

    Some facts,

    Ø  ZoomIt runs on System Tray

    Ø  Allows you to use configurable shortcut key

    This is very lightweight and simple tool. You will enjoy if you use them.

    http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx

    Namoskar!!!

  • Wriju's BLOG

    Visual Studio 2008 : How to zoom Class Diagram

    • 3 Comments

    During my demos I have noticed that Class Diagram in Visual Studio gives a very detailed view with lot of information. Now this is hard for people sitting at the back of the room to see what is there.

    It’s very easy, if you press “CTRL” then scroll the mouse, this will zoom in and out the class diagram.

    Namoskar!!!

  • Wriju's BLOG

    LINQ to SQL : Missing Manual are at MSDN

    • 1 Comments

    ADO.NET and LINQ to SQL

    Describes the relationship of ADO.NET and LINQ to SQL.

     

    Analyzing LINQ to SQL Source Code

    Describes how to analyze LINQ to SQL mapping by generating and viewing source code from the Northwind sample database.

     

    Customizing Insert, Update, and Delete Operations (LINQ to SQL)

    Describes how to add validation code and other customizations.

     

    Data Binding (LINQ to SQL)

    Describes how LINQ to SQL uses IListSource to support data binding.

     

    Inheritance Support (LINQ to SQL)

    Describes the role of inheritance in the LINQ to SQL object model, and how to use related operators in your queries.

     

    Local Method Calls (LINQ to SQL)

    Describes LINQ to SQL support for local method calls.

     

    Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL)

    Provides detailed information for multi-tier applications that use LINQ to SQL.

     

    Object Identity (LINQ to SQL)

    Describes object identity in the LINQ to SQL object model, and explains how this feature differs from object identity in a database.

     

    The LINQ to SQL Object Model

    Describes the object model and its relationship to the relational data model.

     

    Object States and Change-Tracking (LINQ to SQL)

    Provides detailed information about how LINQ to SQL tracks changes.

     

    Optimistic Concurrency Overview (LINQ to SQL)

    Describes optimistic concurrency and defines terms.

     

    Query Concepts in LINQ to SQL

    Describes aspects of queries in LINQ to SQL that differ from queries in LINQ.

     

    Security in LINQ to SQL

    Describes the correct approach to security in database connections.

     

    Serialization (LINQ to SQL)

    Describes the serialization process in LINQ to SQL applications.

     

    Stored Procedures (LINQ to SQL)

    Describes how to map stored procedures at design time and how to call them from your application.

     

    Transactions (LINQ to SQL)

    Outlines the three models of transaction that LINQ to SQL supports.

     

    Type System Mismatches (LINQ to SQL)

    Describes the challenges of mingling different type systems.

     

    User-Defined Functions (LINQ to SQL)

    Describes how to map user-defined functions at design time and how to call them from your application.

     

    Namoskar!!!

     

  • Wriju's BLOG

    LINQ to SQL : Troubleshooting

    • 1 Comments

    Problem with LINQ to SQL? Want to troubleshoot?

    http://msdn.microsoft.com/en-us/library/bb386996.aspx

    Namoskar!!!

  • Wriju's BLOG

    LINQ to SQL FAQ

    • 1 Comments

    List of FAQs are at MSDN http://msdn.microsoft.com/en-us/library/bb386929.aspx

    Namoskar!!!

  • Wriju's BLOG

    What do I have to do if I install IIS after Visual Studio

    • 8 Comments

    What happens if you install you Visual Studio then realize that you need IIS for you application to test and run. We often do this. I have seen people uninstalling Visual Studio and then installing it again after IIS to make sure ASP.NET works fine.

    Wow!! There is an easy way to do it,

    Open the command prompt for Visual Studio 2008. Run the following command

    aspnet_regiis –i

    -i  

    Install this version of ASP.NET and update scriptmaps at  the IIS metabase root and for all scriptmaps below the root. Existing scriptmaps of lower version are upgraded to

    this version. (this is from product documentation help text)

     

    You can also check if the specific ASP.Net version is already attached with IIS by using –lv.

     

    Namoskar!!!

     

  • Wriju's BLOG

    How to find public key token for a .NET DLL or assembly

    • 21 Comments

    Many times we need to get the Public key token for a strongly named assembly in .NET. FAQ on that “how to get the public key token?”. Answer is very simple use the .NET Framework tools sn.exe. So open the Visual Studio 2008 Command Prompt and then point to the dll’s folder you want to get the public key,

    Use the following command,

    sn –T myDLL.dll

    This will give you the public key token. Remember one thing this only works if the assembly has to be strongly signed.

    Example

    C:\WINNT\Microsoft.NET\Framework\v3.5>sn -T EdmGen.exe

    Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.21022.8

    Copyright (c) Microsoft Corporation.  All rights reserved.

     

    Public key token is b77a5c561934e089

    Namoskar!!!

  • Wriju's BLOG

    LINQ to Entity : Querying data using ADO.NET Entity Framework

    • 3 Comments

    ADO.NET Entity Framework have evolved since we have released it first time. Now with the Visual Studio 2008 if you install the .NET Framework 3.5 SP1 and Visual Studio 2008 SP1 you will get the fully functional version of ADO.NET Entity Framework. This is post Beta 3 release.

    To create a .edmx file you have template in Visual Studio 2008,

    Project > Add New Item

    image

     image

    image

    image

    image

    After creating the .edmx file, write the below query,

    using (ObjectContext objC = new ObjectContext("name=NorthwindEntities"))

    {

        ObjectQuery<Customers> custs =

            objC.CreateQuery<Customers>("NorthwindEntities.Customers");

           

        foreach (Customers cust in custs)

        {

            Console.WriteLine(cust.CompanyName);

        }

    }

    Note that this returns Object ObjectQuery<T> which implements IQueryable<T>, which means it will also allow you to write LINQ and this LINQ supports external source. Meaning it will translate the code to T-SQL (if you use MS SQL Server database).

    I feel more comfortable if I use LINQ,

    using (ObjectContext objC = new ObjectContext("name=NorthwindEntities"))

    {

        var custs = from c in

                        objC.CreateQuery<Customers>("NorthwindEntities.Customers")

                    where c.City == "London"

                    select c;

           

        foreach (Customers cust in custs)

        {

            Console.WriteLine(cust.CompanyName);

        }

    }

    Now this is already strongly typed and I do not have to use ObjectContext and ObjectQuery anymore.

    So my pure LINQ to Entity will look like,

    using (NorthwindEntities db = new NorthwindEntities())

    {

        var custs = from c in db.Customers                 

                    where c.City == "London"

                    select c;

           

        foreach (Customers cust in custs)

        {

            Console.WriteLine(cust.CompanyName);

        }

    }

    Namoskar!!!

     

  • Wriju's BLOG

    Bill Gates The Last Day At Microsoft : Bill, we will miss you!!

    • 0 Comments

    Today is the last day for Bill Gates at Microsoft. Bill says “Good Bye” to all Microsoft, his baby, his dream.

    http://www.msnbc.msn.com/id/25417555/?GT1=43001

    Bill we will all miss you.

    Namoskar!!!

  • Wriju's BLOG

    LINQ to SQL: Making it N-Tier

    • 0 Comments

    You can create your application use LINQ to SQL and make it N-Tier. Go ahead and watch out the MSDN Documents

    N-Tier and Remote Applications with LINQ to SQL

    LINQ to SQL N-Tier with ASP.NET

    LINQ to SQL N-Tier with Web Services

    LINQ to SQL with Tightly-Coupled Client-Server Applications

    Implementing Business Logic (LINQ to SQL)

    Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL)

    Namoskar!!!

  • Wriju's BLOG

    Must watch “Gates Looks Back”

    • 1 Comments

    Narrated by Bill Gates himself,

    http://money.cnn.com/magazines/fortune/storysupplement/gates_microsoft/

    Namoskar!!!

  • Wriju's BLOG

    Aspiring Architect Webcast Series 2008

    • 0 Comments

    Dear Architects,

     

    Please block you calendar….

     

    June 16th, 2008 – 12:00 p.m. to 1:00 p.m. – Introduction to the aspiring architect Web Cast series

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380836&Culture=en-CA

     

    June 17th, 2008 – 12:00 p.m. to 1:00 p.m. – Services Oriented Architecture and Enterprise Service Bus – Beyond the hype

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380838&Culture=en-CA

     

    June 18th, 2008 – 12:00 p.m. to 1:00 p.m. – TOGAF and Zachman, a real-world perspective

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380840&Culture=en-CA

     

    June 19th, 2008 – 12:00 p.m. to 1:00 p.m. – Services Oriented Architecture (Web Cast in French)

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380842&Culture=en-CA

     

    June 20th, 2008 – 12:00 p.m. to 1:00 p.m. – Interoperability (Web Cast in French)

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380844&Culture=fr-CA

     

    June 23rd , 2008 – 12:00 p.m. to 1:00 p.m. – Realizing dynamic systems

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380846&Culture=en-CA

     

    June 24th, 2008 – 12:00 p.m. to 1:00 p.m. – Web 2.0, beyond the hype

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380848&Culture=en-CA

     

    June 25th, 2008 – 12:00 p.m. to 1:00 p.m. – Architecting for the user experience

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380850&Culture=en-CA

     

    June 26th, 2008 – 12:00 p.m. to 1:00 p.m. – Conclusion and next steps

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032380852&Culture=en-CA

     

    Namoskar!!!

  • Wriju's BLOG

    Architecture Journal April 2008 : An A-Z Guide to Being an Architect

    • 0 Comments

    While coming to office today I was reading the last article An A-Z Guide to Being an Architect of April 2008 issue. This one is probably the most realistic thought I have ever read about being true architect.

    Some of the cool thoughts,

    Knowledge of technology is only one, albeit important, domain that an architect needs to command.

    As team leader, an architect may not be required to perform line management duties, but may be called upon to be an icon for the rest of the team, providing confidence, insight, motivation, and inspiration.

    Well, not quite. N-tier is a vague term at best

    An architecture framework is a structure that removes some of the wheel reinvention that would otherwise occur.

    This one is a must read article.

    Namoskar!!!

  • Wriju's BLOG

    LINQ to XML : Querying XML with Namespaces

    • 4 Comments

    This question arises in one of discussions. If you have a XML document with “xmlns” then LINQ to XML does not return any IEnumerable<T> J. This is strange but true for XPath and XQuery.

    There is a trick to get it done,

    Let us assume that you have a XML as follows,

    <?xml version="1.0" encoding="utf-8"?>

    <products xmlns="myns-com">

      <product ProductID="1" CategoryID="1">

        <ProductName>Chai</ProductName>

      </product>

      <product ProductID="2" CategoryID="1">

        <ProductName>Chang</ProductName>

      </product>

    </products>

    Now this code holds namespace and all the child element’s default namespace would be that one “myns-com”.

    So if you try to write query against this XML

    var query = from lst in XElement.Load(@"c:\NS.xml").Elements(“product")

                select (int)lst.Attribute("ProductID");

     

    foreach (var k in query)

    {

        Console.WriteLine(k);

    }

    This seems correct though it will not give you any output.

    What you need to do is, you need to the namespace in the query,

    XNamespace ns = "myns-com";

               

    var query = from lst in XElement.Load(@"c:\NS.xml").Elements(ns+"product")

                select (int)lst.Attribute("ProductID");

     

    foreach (var k in query)

    {

        Console.WriteLine(k);

    }

    You will get the desired output as you may expect.

    Namoskar!!!

  • Wriju's BLOG

    Internet Explorer 8 : Will the existing sites break?

    • 1 Comments

    With IE 8 and strong CSS 2.1 compliance, the sites which used to run perfectly fine with IE 7 might break. The error typically could be like, formatting, alignment or JavaScript issues. This is beta and there are ways to prevent all such problems easily.

    We do not have to follow the CSS 2.1 standard to be able to run it in IE 8. If your site runs on IE 7 without any issue the same will run on IE 8 with some simple effort. This has been described well in the KB Article # 952030.

    Option 1:

    In IIS you can add the following header info,

    X-UA-Compatible: IE=EmulateIE7

    Option 2:

    In the web.config under configuration section you can add  add,

    <system.webServer>

      <httpProtocol>

        <customHeaders>

          <clear />

          <add name="X-UA-Compatible" value="IE=EmulateIE7" />

      </customHeaders>

      </httpProtocol>

    </system.webServer>

     

    Option 3:

    You can modify a single page by adding meta tag,

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

        <title>Untitled Page</title>

        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

           

        </div>

        </form>

    </body>

    </html>

    Find more on Microsoft's Interoperability Principles and IE8.

    Namoskar!!!

Page 17 of 25 (609 items) «1516171819»