gpt4 book ai didi

entity-framework - Breeze.js 不支持具有 TimeSpan 属性的 EF 实体?

转载 作者:行者123 更新时间:2023-12-04 05:18:12 24 4
gpt4 key购买 nike

在向 DocCode 项目中的 Employee 实体添加 TimeSpan 属性后,我收到 NotSupportedException 。所以我知道它不受支持,但是......是否有计划进行转换或解决此问题的方法。我们在实体中广泛使用 TimeSpan,有没有办法支持 TimeSpan 或计划支持?

  • 添加持续时间属性

  • public class Employee
    {
    ...
    public DateTime? HireDate { get; set; }

    public TimeSpan? Duration { get; set; }

    [MaxLength(60)]
    public string Address { get; set; }
    ...
    }


    当在运行单元测试的 NorthwindController 上调用 MetaData() 方法时,它会失败:
    System.NotSupportedException was unhandled by user code
    HResult=-2146233067
    Message=There is no store type corresponding to the EDM type 'Edm.Time(Nullable=True)' of primitive type 'Time'.
    Source=System.Data.SqlServerCe.Entity
    StackTrace:
    at System.Data.SqlServerCe.SqlCeProviderManifest.GetStoreType(TypeUsage edmType)
    at System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.MapTableColumn(EdmProperty property, DbTableColumnMetadata tableColumnMetadata, Boolean isInstancePropertyOnDerivedType, Boolean isKeyProperty)
    at System.Data.Entity.ModelConfiguration.Edm.Services.PropertyMappingGenerator.Generate(EdmEntityType entityType, IEnumerable`1 properties, DbEntitySetMapping entitySetMapping, DbEntityTypeMappingFragment entityTypeMappingFragment, IList`1 propertyPath, Boolean createNewColumn)
    at System.Data.Entity.ModelConfiguration.Edm.Services.EntityTypeMappingGenerator.Generate(EdmEntityType entityType, DbDatabaseMapping databaseMapping)
    at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(EdmModel model, DbDatabaseMapping databaseMapping)
    at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel model)
    at System.Data.Entity.ModelConfiguration.Edm.EdmModelExtensions.GenerateDatabaseMapping(EdmModel model, DbProviderManifest providerManifest)
    at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
    at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
    at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
    at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
    at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
    at System.Data.Entity.Internal.InternalContext.Initialize()
    at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
    at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
    at Breeze.WebApi.EFContextProvider`1.GetCsdlFromObjectContext(Object context)
    at Breeze.WebApi.EFContextProvider`1.GetCsdlFromDbContext(Object context)
    at Breeze.WebApi.EFContextProvider`1.BuildJsonMetadata()
    at Breeze.WebApi.ContextProvider.Metadata()
    at DocCode.Controllers.NorthwindController.Metadata() in c:\Users\anwalker\Downloads\breeze-runtime-plus-0.78.2\Samples\DocCode\DocCode\Controllers\NorthwindController.cs:line 20
    at lambda_method(Closure , Object , Object[] )
    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
    at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
    InnerException:

    最佳答案

    好的,经过一些研究,使用 ISO8601 'duration' 标准将 .NET 时间跨度序列化到 javascript 客户端是有意义的,该标准将时间跨度以天、小时、分钟和秒表示为格式字符串,例如:“PnnnDTnnHnnMnn .nnnS”。显然,您将需要客户端上的 javascript 库来解释和使用它。这会满足您的需求吗?

    我已将此添加到我们的功能请求日志中,但也请将其添加到 Breeze User Voice (并投票给它:))。这有助于我们优先处理未完成的功能请求。

    关于entity-framework - Breeze.js 不支持具有 TimeSpan 属性的 EF 实体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13982046/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com