Monday, August 30, 2010

Silverlight CRUD Operations Using WCF Service

Image3.jpg
This articles will demonstrates how to use Silverlight CRUD operations using WCF service. We are going to use Data Grid data control.
Create a new Silverlight project using .NET framework 4.
You will see project layout like this. Web project works like server project all database related classes and services, .aspx test pages, configuration file and other project has all .xaml pages controls.
Now add a new Silverlight enabled wcf service.
In this sample I am using NORTHWND database which is available in App_Data folder. First add a new class in web project.
Customers.cs
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
namespace SilverlightCRUD_Using_WCFService.Web
{

public class Customers
{
public string CustomerID { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }        
}
}

Now add functions in service class. This is connection string.
string conn = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NORTHWND.MDF;Integrated Security=True;User Instance=True";
Read more: C# Corner