Thursday, October 30, 2008


ObservableCollection Class its a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.

WPF provides the ObservableCollection class, which is a built-in implementation of a data collection that implements the INotifyCollectionChanged interface

In WPF data binding The INotifyPropertyChanged interface is used to notify clients, typically binding clients, that a property value has changed.

Suppose you have UDT (User Defined Type object) called Address which Implements the INotifyPropertyChanged Interface and has the the following fields defined Name,Phone,Email these Fields are bind to WPF controls called TextBox, anywhere in the program any one of the field is changed the INotifyPropertyChanged interface event PropertyChanged event fired.
so that WPF user control can updated with New value.


Wednesday, October 29, 2008

Contextual Keywords in C#

Contextual Keywords in C#

Keywords are predefined reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in program unless they include @ as a prefix. For example, @if is a legal identifier but if is not because it is a keyword.

A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#.

forexample :

var query = from customer in db.Customer where"Chennai"
select customer;

here where is the Contextual keyword it has significant meaning , but outside of this statement where has no meaning so we can use as an identifier.

C# Contextual Keywords

get , partial , set ,value , where , yield


Tuesday, October 28, 2008

WCF Service design guidelines

I followed the following design guidelines for WCF Service with respect of SOA.

1. Service Interface Design [ Service Contract]

Design Service contract that has meaning full operation contract and Indivisible.
Avoid unrelated Operation contracts in the same Service contract.

Include Service operation which has same meaning this is good SOA Practice.
For example in my project a Service Contract defines the following operations like creating, updating, canceling, or inquiring a records.

Use the most efficient messaging pattern for each Service operations
o Request/Reply – Default, even if Operations returns void.

o One-Way -Don’t return a result if there is no use for it. Specify the asynchronous IsOneWay=true setting for an operation if a client does not need to wait for the operation to complete.

o Duplex

Use Data Structure are Contract familiar to the client, do not user System specific data types.[for 100 % interoperability ].

Data contract should be defined and explained which is used in Operation Contract.

2. Service Class Design [ Service Contract Implementation]

Separate Service implementation from Service Interface
Use the same names for both but prefix the service interface with an I.
Make an up-front decision about which instancing model you will use (per call, per session, singleton).[ specify with Service Behavior attribute].
Avoid stateful [Session] service if possible.

Write thread-safe code, so your service can take advantage of multiple-thread concurrency (the default behavior). If it is not possible to write thread-safe code for some reason, be sure to set concurrency mode to single.

Avoid lengthy Service operations that my time out before completed executing

3. Service Hosting

IIS-hosted services provide a number of compelling features, including automatic activation, health monitoring, process recycling, compile-on-demand, and the ability to update the application or its config while still running. IIS also makes it easy to accomplish some things that are hard to do in code, such as supporting SSL. However, IIS also has some limitations. You are limited to the HTTP/S transport (unless using IIS 7.0).


Monday, October 27, 2008

Microsoft Pre-release Software Visual Studio 2010 and .NET Framework 4.0 Community Technology Preview (CTP)

Microsoft Visual Studio 2010 and the .NET Framework 4.0 are the next generation development tools and platform for Windows Vista, the 2007 Office System, and the Web

Here is the Link where you can download.


தீபாவளி வித் சில்வர் Light

Deepavali is festival of Light , so let us celebrate the great Festival with SILVER LIGHT


Thursday, October 23, 2008

Simple Rich User Experience with SilverLight 2.0

In this post i am going write a Silver Light client consumes the WCF Service which has the Operation contract called GetCustomers that returns a list of customers from NorthWind Database. This SL 2.0 client supports pagination of the Customers records with Slider Controls.

Step to Create the Application

1) Create a Silver Light Application (web).

2) Add WCF service template or Silver Light-enabled WCF service template to Silver Light Application Testing project.

3) Add OperationContract called GetCustomers in Service.cs.

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace DBPagenation.Web
// NOTE: If you change the interface name "ISreeniDataService" here, you must also update the reference to "ISreeniDataService" in Web.config.
public interface ISreeniDataService

List GetCustomers(int pageNumber);

4) Add LINQ to SQL Classes and create a data class by dragging Customers table from server Explorer. And change the serialization mode properties to Unidirectional. This properties make data class as realizable [DataContract].

Silver Light UI CODE:

using Slider control now navigate different pages of customer records instead of clicking old style like 1 2 3 4 5...


Wednesday, October 22, 2008

Database Records Pagination in LINQ to SQL

Database Records Pagination in LINQ to SQL

Before diving in directly to how we can achieve DB Records pagination in LINQ to SQL, I wanted to give little glance about C# 3.0 partitioning operators Take, Skip, TakeWhile, SkipWhile.

The partitioning operator’s returns subset of a collection with these operators you will get partial result.

With Take you need to specify number of elements to take from the collections.

Skip will ignore the specified number of elements and take the rest.

TakeWhile takes the elements as long as the condition is true.

SkipWhile Bypasses elements in a collection as long as a specified condition is true and then returns the remaining elements from collection.

Today there was a requirement in my project I need to return the customer records in addition to pagination. Using LINQ to SQL I am selecting all customer records from customer table. Partitioning operators are needed for pagination of customer records.

Here is the code snippet

// Page size is configurable in app.config or web.config.
int pageSize = int.Parse(configSec.Get("PageSize").Trim());

var customerRecrods = from customer in dbconn.APVENMASTs
join custAddress in dbconn.APVENADDRs on customer.VENDOR.Trim() equals custAddress.VENDOR.Trim()
select new RefineryProfile

name = customer.VENDOR_VNAME,

customerNumber = customer.VENDOR,

phoneNumber = customer.PHONE_NUM,

postalCode = custAddress.POSTAL_CODE,

city = custAddress.CITY_ADDR5,

address = custAddress.ADDR1,

address1 = custAddress.ADDR2,
return customerRecrods.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();


.NET 4.0, WF/WCF, and Oslo

Model Driven Programming
Its less than a week for PDC-2008. At PDC MS Tech Engineers will unveiled the new VS.NET 2010 and .NET 4.0

Here is the link where you can get more information


Tuesday, October 21, 2008

LINQ to XML How to add Namespace when parsing the XML


If you look at my pervious BLOG , were i am using weather webservice to get weather information for given Zipcode. this Webmethod call returns XML Data. when i parse Weather service response XML i am always getting the null values for the XML element i was querying.

Finally i found out that to access these elements we need to add XML Namespace to Xname. here is the code which shows how i did that.

private void ParsexWeatherXml(string exml)
XNamespace ns = ""; // Weather Service Namespace
XDocument weatherData = XDocument.Parse(exml );
var query = from data in weatherData.Descendants(ns + "WeatherData")

select new WeatherData
day = (string)data.Element(ns + "Day").Value ,
urlImage =(string) data.Element(ns+"WeatherImage").Value,
maxTemp = (string)data.Element(ns + "MaxTemperatureF").Value,
minTemp = (string)data.Element(ns + "MinTemperatureF").Value
datag.ItemsSource = query;



Monday, October 20, 2008

SilverLight 2 [Calling Weather WebService]

Silverlight client calling the following Weather Service

1) Create VS.NET 2008 Silverliight Appliciaton

2) This will create or Add two projects into solution. one is SilverLight UI project and Testing project which has both .ASPX and HTML pages.

3) The above webService expose the following two web methods
GetWeatherByPlaceName Get one week weather forecast for a place name(USA) GetWeatherByZipCode Get one week weather forecast for a valid Zip Code(USA)
In this project i am using Get WeatherInfo by Zipcode using HTTP-GET method.

4) To Invoke the above webservice we need to use the WebClient class from the follwoing .NET assembly System.Data.Services.Client.dll .

5) GetWeatherByZipCode method returns XML data which has Weekly weather information as shown below.

using LINQ to XML Parse the XML Data and create the WeatherData .NET UDT (user defined Type ) object.

public class WeatherData
public string day { get; set; }
public string urlImage { get; set; }
public string maxTemp { get; set; }
public string minTemp { get; set; }



This is my First Blog

Hi Friends
I am working as Architect in MS Technolgoies with HITACHI CONSULTING .
I will be bloging now and then but i can not promise daily in the following related Technologies

1) WCF 3.5
2) WPF and SilverLight 2.0
3) WF
4) ADO.NET Data Services
5) C# 3.0
6) MOSS 2007
7) BizTalk 2006
8) SQL SSRS, etc..
9) LINQ to (SQL, XML,Data)