Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Odata更改为使用System.DateTimeOffset或通过调用ignore忽略此类型_C#_Asp.net Mvc_Odata - Fatal编程技术网

C# Odata更改为使用System.DateTimeOffset或通过调用ignore忽略此类型

C# Odata更改为使用System.DateTimeOffset或通过调用ignore忽略此类型,c#,asp.net-mvc,odata,C#,Asp.net Mvc,Odata,我在以下方面有一个odata错误: config.MapODataServiceRoute( "ODataRoute", "odata", builder.GetEdmModel()); 错误:类型'System.Nullable'1[[System.DateTime,mscorlib, 版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089]' “订单”类型中的属性“NextBillingDate”不受支持 类型更改为使用“System.Dat

我在以下方面有一个odata错误:

  config.MapODataServiceRoute( "ODataRoute", "odata", builder.GetEdmModel());
错误:类型'System.Nullable'1[[System.DateTime,mscorlib, 版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089]' “订单”类型中的属性“NextBillingDate”不受支持 类型更改为使用“System.DateTimeOffset”或通过忽略此类型 在上调用Ignore() 'System.Web.OData.Builder.ODataModelBuilder'。参数名称: 导航属性

我什么都试过了。。。发件人:

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());

    }
公共静态无效寄存器(HttpConfiguration配置)
{
ODataModelBuilder=新ODataConventionModelBuilder();
EntitySetConfiguration client=builder.EntitySet(“client_V1”);
EntitySetConfiguration cupon=builder.EntitySet(“优惠券V1”);
EntitySetConfiguration order=builder.EntitySet(“Orders_V1”);
client.EntityType.Ignore(x=>x.CreatedOn);
client.EntityType.Ignore(x=>x.ModifyOn);
client.EntityType.Ignore(x=>x.LastLogin);
忽略(x=>x.Start);
忽略(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”,
模型:builder.GetEdmModel());
}

.net是否忽略order.EntityTyper()?

更糟糕的是,尽管我的字段不可为空,但还是出现了此错误。似乎DateTime并不完全受支持。看到这个答案了吗