C# 他失踪了?

C# 他失踪了?,c#,orm,fluent-nhibernate,C#,Orm,Fluent Nhibernate,我有一个非常简单的映射,我正在尝试。我正在学习NHibernate 3.0的食谱,遇到了FluentNHibernate.dll中缺少naturaid()方法的问题。这本书让我做了这样一件事: using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentNHibernate.Mapping; using Eg.Core; namespace Eg.Fluent

我有一个非常简单的映射,我正在尝试。我正在学习NHibernate 3.0的食谱,遇到了FluentNHibernate.dll中缺少naturaid()方法的问题。这本书让我做了这样一件事:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Eg.Core;

namespace Eg.FluentMappings.Mappings
{
    public class ProductMapping : ClassMap<Product>
    {
        public ProductMapping()
        {
            Id(p => p.Id)
                .GeneratedBy.GuidComb();
            DiscriminateSubClassesOnColumn("ProductType");
            Version(p => p.Version);
            NaturalId()
                .Not.ReadOnly()
                .Property(parentIsRequired => parentIsRequired.Name);
            Map(p => p.Description);
            Map(p => p.UnitPrice)
                .Not.Nullable();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用FluentNHibernate.Mapping;
使用例如核心;
名称空间,例如FluentMappings.Mappings
{
公共类ProductMapping:ClassMap
{
公共产品映射()
{
Id(p=>p.Id)
.GeneratedBy.GuidComb();
区分子类别子列(“产品类型”);
版本(p=>p.Version);
归化的
.Not.ReadOnly()
.Property(parentIsRequired=>parentIsRequired.Name);
地图(p=>p.Description);
地图(p=>p.单价)
.Not.Nullable();
}
}
}
当我试图编译它时,我得到一个错误:名称“NaturalId”在当前上下文中不存在。我是否丢失了另一个dll或其他东西


我环顾四周,发现了很多。这里有一个问题似乎得到了回答,但我无法使用
map.NaturalId()
map.NaturalId()
使其正常工作

找到了答案。不确定原因,但您必须在NaturalId()上使用base关键字。以下是我的修订课程:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Eg.Core;

namespace Eg.FluentMappings.Mappings
{
    public class ProductMapping : ClassMap<Product>
    {
        public ProductMapping()
        {
            Id(p => p.Id)
                .GeneratedBy.GuidComb();
            DiscriminateSubClassesOnColumn("ProductType");
            Version(p => p.Version);
            base.NaturalId()
                .Not.ReadOnly()
                .Property(parentIsRequired => parentIsRequired.Name);
            Map(p => p.Description);
            Map(p => p.UnitPrice)
                .Not.Nullable();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用FluentNHibernate.Mapping;
使用例如核心;
名称空间,例如FluentMappings.Mappings
{
公共类ProductMapping:ClassMap
{
公共产品映射()
{
Id(p=>p.Id)
.GeneratedBy.GuidComb();
区分子类别子列(“产品类型”);
版本(p=>p.Version);
base.naturaid()
.Not.ReadOnly()
.Property(parentIsRequired=>parentIsRequired.Name);
地图(p=>p.Description);
地图(p=>p.单价)
.Not.Nullable();
}
}
}