3. Click OK to create the solution.
The solution contains two projects: a client project and a server project. The client project is named RIAServicesExample and it contains the Silverlight code that you use to create the presentation tier. The server project is named RIAServicesExample.Web and it contains the middle-tier code.
4. Add Edm to your project by graphical interface and set the name default
5. Generate your entity model
6.Choose Connection string by this way
7. Set Data Base Name
8. Select Sql Server
9. Choose Radio button yes and press next button
9. Select Data Base Table or Sp
10.
Delete the two “.tt” generated files in the entity model
11.Open your entity model in the designer and change Code Generation Strategy from "None" to "Default"
12.Rebuild the project and Now you can add a new Domain Service
13.Check Like as image
14.Rebuild your solution and add code to MainPage.xaml page
15.Add the Following code into MainPage.cs Page
16.Build your Solution and Run,now you can see data look like as
17.Thank you
Hello, how can i call a Store Procedure with the connection? Thank You!
ReplyDeleteOpen your entity model and go to properties and choose 'Update Model From DataBase', now you can see your sp, add sp and rebuild your solution. now you will create class like
ReplyDeletepublic class Extension
{
public Customer SetToBusinessObject(spGetAllCustomers_Result result)
{
var bobject = new Customer
{
CustomerID = result.CustomerID,
CompanyName = result.CompanyName,
City = result.City,
Country = result.Country
};
return bobject;
}
}
and create method to your customer service like
public IQueryable GetAllCustomers(string CustomerID)
{
var customerList = this.ObjectContext.spGetAllCustomers(CustomerID).ToList();
var List = customerList.Select(c => new Extension().SetToBusinessObject(c)).ToList();
return List.AsQueryable();
}
and you can call your sp from view model or page code behind
like below
cusContext.Load(cusContext.GetCustomersQuery(customerID), GetAllCustomersCallBack, null);
and call back funtion
private void GetCustomersCallBack(LoadOperation customer)
{
if (customer.Entities == null || customer.HasError) return;
dataGrid.ItemsSource = customer.Entities;
}
i think it is useful to you thanks.