问题描述
"/"应用程序中的服务器错误.
堆栈跟踪:
[HttpException(0x80004005):类型 'System.Nullable`1 [[System.DateTime,mscorlib,Version = 4.0.0.0, 文化=中立,PublicKeyToken = b77a5c561934e089]]' "WebAPIOData.Models.Categoria"类型中的"DataAlteracaoDate"不是 受支持的类型.参数名称:navigationProperty]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext 上下文,HttpApplication应用)+9936761
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext上下文,MethodInfo []处理程序)+118
System.Web.HttpApplication.InitSpecial(HttpApplicationState状态, MethodInfo []处理程序,IntPtr appContext,HttpContext上下文)+172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext上下文)+336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+296
[HttpException (0x80004005): The type 'System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' of property 'DataAlteracaoDate' in the 'WebAPIOData.Models.Categoria' type is not a supported type. Parameter name: navigationProperty]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9936761
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException(0x80004005):类型 'System.Nullable`1 [[System.DateTime,mscorlib,Version = 4.0.0.0, 文化=中立,PublicKeyToken = b77a5c561934e089]]' "WebAPIOData.Models.Categoria"类型中的"DataAlteracaoDate"不是 受支持的类型.参数名称:navigationProperty]
System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文)+254
[HttpException (0x80004005): The type 'System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' of property 'DataAlteracaoDate' in the 'WebAPIOData.Models.Categoria' type is not a supported type. Parameter name: navigationProperty]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
我的班级具有类型为 Nullable<DateTime>
My class has a property "DataAlteracaoDate" of type Nullable<DateTime>
我通过这种方式在ODataModelBuilder上设置实体:
I'm setting the entity on ODataModelBuilder on this way:
builder.EntitySet<Categoria>("Categorias").EntityType.HasKey(t => t.IdCategoria);
我在我的应用中使用的是Prerelease Microsoft.AspNet.OData.5.2.0-rc-140512的最新版本.
I'm using the lasted version for Prerelease Microsoft.AspNet.OData.5.2.0-rc-140512 in my app.
有人有什么建议吗?
推荐答案
DateTime.它支持DateTimeOffset,可以为null或不为null.
DateTime is no longer supported in OData v4. What it supports is DateTimeOffset, either nullable or not.
这篇关于OData v4是否不支持Nullable< DateTime> ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!