Mapping enum enumeration properties for entity framework entities in the context of an ADO.NET Data Service client

I have an entity with fields that are typed int

and I want to show these fields as properties that receive and receive enum type values ​​for strongly typed work.

so I created a new partial class for the object and added two properties.

when I try to create a new instance of TestEntity and add it to the context, and cause the save changes, I get the following exception:

An error occurred while processing this request. in System.Data.Services.Client.DataServiceContext.SaveAsyncResult.HandleBatchResponse () in System.Data.Services.Client.DataServiceContext.SaveAsyncResult.EndRequest () in System.Data.Services.Client.DataServiceContext.SaveChanges (options Save) .Data.Services.Client.DataServiceContext.SaveChanges ()

internal exception:

System.InvalidOperationException: type 'enum1' has no custom properties. in System.Data.Services.Client.ClientType..ctor (Type Type, String typeName, Boolean skipSettableCheck) in System.Data.Services.Client.ClientType.Create (Type Type, Boolean expectModelType) in System.Data.Services.Client .DataServiceContext.WriteContentProperties (XmlWriter writer, ClientType type, object resource) in System.Data.Services.Client.DataServiceContext.CreateRequestData (ResourceBox, Boolean newline field) in System.Data.Services.Client.DataServiceContext.DaveAs , logical new line) in System.Data.Services.Client.DataServiceContext.SaveAsyncResult.BeginNextChange (Boolean replaceOnUpdate)

so I decided that he was trying to reflect the properties of the enumeration as properties of the classes. how can I make the context ignore these properties when it tries to think about them.

I am using VS 2008 Team Suite sp1, SQL Server 2008, .Net 3.5 Sp1.

Reference.

partial class code:

public partial class TestEntity { public enum1 Field1 { get { return (enum1)field1; } set { field1 = (Int16)value; } } public enum2 Field2 { get { return (enum2)field2; } set { field2 = (Int16)value; } } } 
+6
entity-framework wcf-data-services
source share
1 answer

I do not think you can. In ADO.Net data services, you cannot have transfers to proxy objects that are sent to the server. Try changing the object around to use int (or short) instead.

+2
source share

All Articles