Database Reference
In-Depth Information
Change the IService1.cs interface using the code in Listing 9-35.
4.
Listing 9-35. Our IService1 Interface Definition, Which Replaces the Code in IService1.cs
[ServiceContract]
public interface IService1
{
[OperationContract]
void InsertTestRecord();
[OperationContract]
Client GetClient();
[OperationContract]
void Update(Client client);
}
Change the implementation of the IService1 interface in the IService1.svc.cs file with the
code shown in Listing 9-36.
5.
Listing 9-36. The Implementation of the IService1 Interface, Which Replaces the Code in IService1.svc.cs
public class Client
{
[ApplyProxyDataContractResolver]
public Client GetClient()
{
using (var context = new EFRecipesEntities())
{
context.Cofiguration.LazyLoadingEnabled = false;
return context.Clients.Single();
}
}
public void Update(Client client)
{
using (var context = new EFRecipesEntities())
{
context.Entry(client).State =
EntityState.Modified;
context.SaveChanges();
}
}
public void InsertTestRecord()
{
using (var context = new EFRecipesEntities())
{
// delete previous test data
context.ExecuteSqlCommand("delete from chapter9.client");
 
Search WWH ::




Custom Search