问题描述
请 当我说我明白这不是正确"的方式时,请相信我.将其归档在大型复杂遗留系统问题中.
Please believe me when I say I understand this isn't the "right" way to do this. File this under large-complex-legacy-system questions.
我们有一些表描述了文档的OCR数据.每种文档类型都有自己的表.每个表都是根据其期望的字段类型生成的.因此,有一个看起来像这样的模式:
We have tables describing OCR'd data of documents. Each document type has its own table. Each table is generated based on the types of fields it expects. So have a schema which looks a bit like this:
Table: DocumentTypes
Field: Id
Field: Prefix
Table: DocumentFields
Field: Id
Field: DocId
Field: Name
我们将生成如下表:
Table: Type1_Data_Unit1000
Field: Id
Field: DocId
Field: DocField_A_Data
Field: DocField_A_Info1
Field: DocField_A_Info2
Field: DocField_Z_Data
Field: DocField_Z_Info1
Field: DocField_Z_Info2
NHibernate对我们所有其他数据都适用,因为该模式更加静态.
NHibernate works well for all of our other data because the schema is more static.
我的问题: 是否可以将nhibernate配置为加载其中一个DataTable并将一系列字段绑定到一个集合中?如果是的话,我应该从哪个界面开始寻找?
My question: Is it at all possible to configure nhibernate to load one of the DataTables and bind the series of fields into a collection? If it is, at what interfaces should I start looking?
我的想法是开设一个像这样的课程:
My idea is to have a class which is something like:
class FormData
{
public virtual int Id {get;set;}
public virtual int DocId {get;set;}
public virtual int Id {get;set;}
public virtual IList(Of FormFieldData) {get;private set;}
}
class FormFieldData
{
public virtual int Id {get;set;}
public virtual string Value {get;set;}
public virtual int Info1 {get;set;}
public virtual int Info2 {get;set;}
}
我稍微看了一下"IInterceptor",并认为那是我应该首先看的地方.但是在投资几天之前,我想让SO人群来经营它.
I've looked at "IInterceptor" a little bit and think that's where I should look first. But before investing days in it, I wanted to run it by the SO crowd.
谢谢!
推荐答案
如果架构不是静态的,那么nhibernate甚至很难创建查询-并且拦截器无法帮助您我很担心.我将使用纯CreateSQLQuery并随后手动处理返回的值.
If the schema isn't static, then it'll be hard for nhibernate to even create the query - and intercepters can't help you there as far as I'm concerned. I'd go with pure CreateSQLQuery and manipulating the returned values manually afterwards.
这篇关于如何使用NHibernate将一系列列绑定到集合中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!