2

DocCode プロジェクトの Employee エンティティに TimeSpan プロパティを追加した後、NotSupportedException が発生します。だから私はそれがサポートされていないことを知っていますが...変換を行う計画、またはこれを乗り越える方法はありますか. エンティティで TimeSpan を広く使用していますが、TimeSpan をサポートする方法や計画はありますか?

  1. 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: 
4

3 に答える 3

2

TimeSpan のサポートは、ビルド 0.84.1 で追加されました。

TimeSpans は、ブリーズ クライアントでは ISO 8601 の「期間」文字列として表されます。http://en.wikipedia.org/wiki/ISO_8601を参照

完全なクエリ サポートには、TimeSpan/Duration プロパティをフィルター処理して返す機能が含まれています。すなわち

var query = EntityQuery.from("Contracts").where("TimeElapsed", ">", "PT4H30M");
于 2013-01-09T18:02:24.740 に答える
1

OK、少し調査した後、次のようなフォーマットされた文字列としてタイムスパンを日、時間、分、秒で表す ISO8601 'duration' 標準を使用して、JavaScript クライアントに .NET タイムスパンをシリアル化することは理にかなっています。 .nnnS". 明らかに、これを解釈して操作するには、クライアントに JavaScript ライブラリが必要です。これはあなたのニーズを満たすでしょうか?

これを機能リクエスト ログに追加しましたが、Breezeユーザーの声にも追加してください(そして投票してください :))。これにより、未解決の機能リクエストに優先順位を付けることができます。

于 2012-12-21T00:41:54.003 に答える
0

うーん.. リクエストは理にかなっています。しかし、JavaScript、文字列、ある時点からの秒数、または.NETタイムスパンの標準JavaScript表現はありますか?

于 2012-12-20T23:50:17.990 に答える