我有一个odata错误:
config.MapODataServiceRoute( "ODataRoute", "odata", builder.GetEdmModel());
错误:类型' System.Nullable`1 [[System.DateTime,mscorlib, Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]' 属性' NextBillingDate'在'命令'类型不受支持 类型。更改使用' System.DateTimeOffset'或忽略此类型 调用Ignore() ' System.Web.OData.Builder.ODataModelBuilder&#39 ;.参数名称: navigationProperty
我已经尝试过所有......来自:
public class ZOrder
{
public Guid ID { get; set; }
[Display(Name = "NexBillingDate", ResourceType = typeof(Resource))]
[ScriptIgnoreAttribute]
[IgnoreDataMember]
public DateTime? NextBillingDate { get; set; }
[NotMapped]
public DateTimeOffset? NexBillingDateOffSet
{
get { return NextBillingDate; }
set { NextBillingDate = Convert.ToDateTime(value); }
}
}
[IgnoreDataMember],[ScriptIgnoreAttribute],没有任何作用......我也尝试过:
public static void Register(HttpConfiguration config)
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
EntitySetConfiguration<Client> client = builder.EntitySet<Client>("Client_V1");
EntitySetConfiguration<Coupon> cupon = builder.EntitySet<Coupon>("Coupon_V1");
EntitySetConfiguration<Order> order = builder.EntitySet<Order>("Orders_V1");
client.EntityType.Ignore(x => x.CreatedOn);
client.EntityType.Ignore(x => x.ModifyOn);
client.EntityType.Ignore(x => x.LastLogin);
cupon.EntityType.Ignore(x => x.Start);
cupon.EntityType.Ignore(x => x.End);
order.EntityType.Ignore(x => x.NextBillingDate);
order.EntityType.Ignore(x => x.CreatedOn);
order.EntityType.Ignore(x => x.ModifyOn);
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: "odata",
model: builder.GetEdmModel());
}
是.net忽略order.EntityTyper()??