Fluent NHibernate 映射问题
我有以下类和表,我想了解如何在 Fluent Nhibernate 中映射它:
class File
{
public virtual int Id { get; set; }
public virtual IList<FileParameter> FileParameters { get; set; }
public virtual IList<File> DetailFile { get; set; }
}
class FileParameter
{
public virtual int Id { get; set; }
public virtual File MasterFile { get; set; }
public virtual string Name { get; set; }
public virtual string DisplayName { get; set; }
public virtual FileParameterValue FileParameterValue { get; set; }
}
class FileParameterValue
{
public virtual int Id { get; set; }
public virtual File ParentFile { get; set;}
public virtual FileParameter FileParameter { get; set; }
public virtual string DefaultValue { get; set; }
public virtual bool DisplayStatus { get; set; }
}
数据库表
Table File
FileId,
Table FileParameter
ParameterId, FileId, Name, DisplayName
Table FileParameterValue
FileParameterValueId, ParameterId, FileId, DefaultValue, DisplayStatus
我想要实现的是,有一个主文件及其许多详细信息文件。每个主文件都有自己的 FileParameter 和 FileParameValue。主文件的每个子文件都使用主文件的 FileParameter,但具有自己的 FileParameterValue。
任何理想都会非常感激。
I have the following classes and tables, I want to find out how to map it in Fluent Nhibernate:
class File
{
public virtual int Id { get; set; }
public virtual IList<FileParameter> FileParameters { get; set; }
public virtual IList<File> DetailFile { get; set; }
}
class FileParameter
{
public virtual int Id { get; set; }
public virtual File MasterFile { get; set; }
public virtual string Name { get; set; }
public virtual string DisplayName { get; set; }
public virtual FileParameterValue FileParameterValue { get; set; }
}
class FileParameterValue
{
public virtual int Id { get; set; }
public virtual File ParentFile { get; set;}
public virtual FileParameter FileParameter { get; set; }
public virtual string DefaultValue { get; set; }
public virtual bool DisplayStatus { get; set; }
}
Databse table
Table File
FileId,
Table FileParameter
ParameterId, FileId, Name, DisplayName
Table FileParameterValue
FileParameterValueId, ParameterId, FileId, DefaultValue, DisplayStatus
What I want to achieve is that, there is one master file and its many details files. Each master file has its own FileParameter, and FileParameValue. Each of the master file's child files use the master file's FileParameter, but has its own FileParameterValue.
Any ideal would be very much appreicated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须以编程方式确保,如果您在详细信息文件中添加参数值,则使用主文件的参数对象,
另请参阅类似问题NHibernate 映射
you have to make sure programmatically, that if you add a parametervalue in a detailsfile you use a parameter-object of the master file
see also for a similar problem NHibernate mapping