Tuesday, September 1, 2009

Outlook type Address Book in C#, LINQ, XML with Menu and ToolBar


This is a sample project to create outlook type address book with LINQ and XML. It also shows how to use menu and toolbars in your windows application.


LINQ ( Language Integrated Query) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. It allows you to query collections like arraylist, List etc. LINQ to XML is a new way to construct, write and read XML data in the .NET language of the developers’ choice. This new API simplifies working with XML data without having to resort to using additional language syntax like XPath or XSLT. LINQ to XML is not a replacement for any of the current DOM’s or XML class libraries; LINQ to XML in many cases overlaps their functionality and aims to provide a superior developer experience, but existing code will continue to work. One aspect of LINQ to XML is that it supports writing Query Expressions and can be combined with any of the other LINQ technologies to create or use XML data as a source or destination format.

Using the code

The Address Book is created in C# with XML as a database to store the contacts. Addition, deletion and updation of the records to this XML file is done with LINQ.

Most the coding is easy to understand as you go through the sample project. I will explain you how I am uisng LINQ to work with my XML file.

Make sure you have reference to System.LINQ and System.XML.LINQ in order to work with LINQ to XML.

If you go through the static class XMLParse you will se that all the coding related to LINQ is done here. Let me explain you how it works.

create a new XDocument class object like this

See full detail: http://www.codeproject.com/KB/linq/AddressBook.aspx