My name is Phani and I am working on the ADO.NET Data Services team.
The ResolveName and ResolveType will help you configure the type information that the client writes to the payload sent to the server and as a tangible implementation of the payload from the server.
They help you resolve types on the client and are useful in many scenarios, a few examples:
- The hierarchy of object types on the client is different from the server.
- The types of objects provided by the service participate in inheritance, and you want to work with derived types on the client.
ResolveName used to change the name of the object that we put in the wire when we make a request to the server.
Consider this data model: On the server
public class Employee { public int EmployeeID {get;set;} public string EmployeeName {get;set;} } public class Manager:Employee { public List<int> employeesWhoReportToMe {get;set;} }
When you use the client to work with instances of type Entity Manager, when sending changes to the server, we expect the type information to be present in the payload when entities participate in inheritance.
context.AddObject("Employees",ManagerInstance ); <-- add manager instance to the employees set. context.SaveChanges();
However, when the client serializes this payload, it puts "Employee" as a type name that is not expected on the server. Therefore, you must indicate the name of the client on the client,
context.ResolveName = delegate(Type entityType){
Similarly, a type recognizer is used.
context.ResolveType = delegate(string entitySetName){
source share