我正在使用automap映射域模型(简化版本):
public class AppUser : Entity
{
[Required]
public virtual string NickName { get; set; }
[Required]
[DataType(DataType.Password)]
public virtual string PassKey { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public virtual string EmailAddress { get; set; }
public virtual IList<PreferencesDescription> PreferencesDescriptions { get; set; }
}
public class PreferencesDescription : Entity
{
public virtual AppUser AppUser { get; set; }
public virtual string Content{ get; set; }
}PreferencesDescriptions集合映射为IList,索引集合也是如此(当我需要使用ICollection的标准未索引集合时)。
事实上,fluent nhibernate的automap工具将我的域模型映射为一个未索引的集合(因此在SchemaExport生成的DDL中没有“位置”属性)。
,我如何才能做到这一点而不必覆盖这种情况--我的意思是,如何使Fluent nhibernate的自动生成始终用于IList而不是ICollection的索引集合?
发布于 2010-03-10 15:56:28
IList不是索引集合。您可以按索引访问IList中的元素,但它们的位置不存储在数据库中。您不能按索引访问ICollection (不使用扩展方法),但它确实有一个AddAt方法来在索引处向集合添加对象。
如果需要在集合中存储对象位置,请将其映射为等同于地图的IDictionary。我假设自动化程序将使用map作为IDictionary集合类型。
https://stackoverflow.com/questions/1514481
复制相似问题