Hello,
I have a WCF service which performs CRUD operation on my data model: Add, Get, Update and Delete. And I'm using Entity Framework for my data model. On the other side there is a client application which calls methods of the WCF service.
For example I have a Customer class:
[DataContract]
public class Customer
{
public Guid CustomerId {get; set;}
public string CustomerName {get; set;}
}
and WCF service defines this method:
public void AddCustomer(Customer c)
{
MyEntities _entities = new MyEntities();
_entities.AddToCustomers(c);
_entities.SaveChanges();
}
and the client application passes objects to the WCF service:
var customer = new Customer(){CustomerId = Guid.NewGuid, CustomerName="SomeName"};
MyService svc = new MyService();
svc.Add(customer); // or svc.Update(customer) for example
But when I need to pass a great amount of objects to the WCF it could be a perfomance issue because of I need to create ObjectContext each time when I'm doing Add(), Update(), Get() or Delete().
What I'm thinking on is to keep ObjectContext on the client and pass ObjectContext to the wcf methods as additional parameter.
Is it possible to create and keep ObjectContext on the client and don't recreate it for each operation? If it is not, how could speed up the passing of huge amount of data to the wcf service?
Sergey