EF实体具有Breeze.js中不支持的时机属性



我在DOCCODE项目中的员工实体中添加了timespan属性后,我将获得一个notsupportedexception。因此,我知道这不受支持,但是...是否有计划进行转换或解决此问题的方法。我们在我们的实体中广泛使用时间板,有没有办法支持时间潘普或计划?

  1. 添加了持续时间属性
public class Employee
{
    ...
    public DateTime? HireDate { get; set; }
    public TimeSpan? Duration { get; set; }
    [MaxLength(60)]
    public string Address { get; set; }
    ...
}

当在运行单元测试的NorthwindController上调用元数据()方法时,它会失败:

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:UsersanwalkerDownloadsbreeze-runtime-plus-0.78.2SamplesDocCodeDocCodeControllersNorthwindController.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: 

在构建0.84.1中添加了timepan支持。

TimePans在微风客户端上表示为ISO 8601"持续时间"字符串。参见http://en.wikipedia.org/wiki/iso_8601

完整的查询支持包括过滤和返回时间板/持续时间属性的能力。即。

var query = EntityQuery.from("Contracts").where("TimeElapsed", ">", "PT4H30M");

好吧,经过一番研究,使用ISO8601'持续时间'标准序列化.NET TIMESPAN到JavaScript客户端,该标准将在几天,小时,分钟,分钟,分钟,分钟,分钟,分钟,分钟,分钟,分钟,分钟,分钟,分钟秒为格式的字符串,例如:" pnnndtnnnnnnn.nnns"。显然,您需要在客户端上的JavaScript库来解释和使用此功能。这会满足您的需求吗?

我已经将其添加到我们的功能请求日志中,但请将其添加到Breeze用户语音中(并为其投票:)。这有助于我们优先考虑出色的功能请求。

hm ..请求很有意义。但是,您希望它将其转换为JavaScript,一个字符串或数量以后的时间点或......是否有.NET TIMESPAN的标准JavaScript表示形式?

最新更新