在将 TimeSpan 属性添加到 DocCode 项目中的 Employee 实体后,我收到了 NotSupportedException。所以我知道它不受支持,但是......是否有计划进行转换或克服这个问题的方法。我们在实体中广泛使用 TimeSpan,有没有办法支持 TimeSpan 或计划?
- 添加了 Duration 属性
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: