ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c#-实体框架5-抽象类型’X’没有映射的后代,因此无法映射

2019-10-31 22:08:26  阅读:251  来源: 互联网

标签:quickfix entity-framework-5 fix-protocol c entity-framework


尝试在this object上操作时出现以下错误.有人有想法吗? project在GitHub上,但是除非周围有FIX服务器,否则您极有可能无法运行它.我似乎无法联网此错误消息.

    System.InvalidOperationException was unhandled by user code
      Message=The abstract type 'QuickFix.Fields.IField' has no mapped descendents and so cannot be mapped. Either remove 'QuickFix.Fields.IField' from the model or add one or more types deriving from 'QuickFix.Fields.IField' to the model. 
      Source=EntityFramework
      StackTrace:
           at System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.GetEntityTypeMappingInHierarchy(DbDatabaseMapping databaseMapping, EdmEntityType entityType)
           at System.Data.Entity.ModelConfiguration.Edm.Services.AssociationTypeMappingGenerator.GenerateIndependentAssociationType(EdmAssociationType associationType, DbDatabaseMapping databaseMapping)
           at System.Data.Entity.ModelConfiguration.Edm.Services.AssociationTypeMappingGenerator.Generate(EdmAssociationType associationType, DbDatabaseMapping databaseMapping)
           at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateAssociationTypes(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.GetEntitySetAndBaseTypeForType(Type entityType)
           at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
           at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
           at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
           at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
           at System.Data.Entity

解决方法:

QuickFix Message对象不是简单的DTO,这使它们不适合使用任何ORM映射到数据库. QuickFix为每种FIX字段类型定义了一个不同的IField派生类.这意味着您将必须将IField接口映射到数据库以及每个单独的字段类型.

更糟的是,QuickFix / N是Java的移植版,其中包含许多Javaism,这使得映射非常困难,例如使用getter / setter方法代替属性.
另一个障碍是,每个FIX版本都有一个单独的名称空间,这意味着如果要为所有FIX版本保留消息,则必须使用稍微相同的类来映射4-5个不同的名称空间.

更好的选择是创建单独的DTO对象,您可以将其映射到数据库并将QuickFix Message对象转换为DTO.幸运的是,QuickFix包含XML格式的各种版本的FIX的数据字典,您可以使用它们使用代码生成器生成DTO.

为了简化转换,您可以使用基于约定的工具(例如AutoMapper)将QuickFix对象转换为DTO,而无需自己编写转换代码.

标签:quickfix,entity-framework-5,fix-protocol,c,entity-framework
来源: https://codeday.me/bug/20191031/1978956.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有