使用不存在的方法的无效代理类型异常 - Fluent NHibernate

时间:2013-01-24 14:30:40

标签: c# nhibernate fluent-nhibernate

以下一次更新

我有以下类派生自EqualityComparer<T>,我(尝试)使用Fluent / NHibernate持久化。

public class WeeklyGSFEntity : EqualityComparer<WeeklyGSFEntity>
{
    public virtual int IssueNumber { get; set; }
    public virtual int Severity { get; set; }
    public virtual char PainIndex { get; set; }
    public virtual Status Status { get; set; }
    public virtual int Month { get; set; }
    public virtual int Year { get; set; }
    public virtual DateTime DateCreated { get; set; }
    public virtual Region Region { get; set; }
    public virtual DateTime IncidentStart { get; set; }
    public virtual DateTime IncidentEnd { get; set; }
    public virtual int SRCount { get; set; }
    public virtual string AggravatingFactors { get; set; }
    public virtual string AggravatingFactorDescription { get; set; }
    public virtual TimeSpan MTTR
    {
        get
        {
            return (IncidentEnd - IncidentStart);
        }
    }

    public WeeklyGSFEntity()
    {
        Status = Status.New;
    }
    public override int GetHashCode() { ... }

    internal static bool StaticEqual(WeeklyGSFEntity x, WeeklyGSFEntity y) { ... }
    public static bool operator ==(WeeklyGSFEntity x, WeeklyGSFEntity y) { ... }
    public static bool operator !=(WeeklyGSFEntity x, WeeklyGSFEntity y) { ... }
    public override bool Equals(WeeklyGSFEntity x, WeeklyGSFEntity y) { ... }
    public override bool Equals(object obj) { ... }
    public override int GetHashCode(WeeklyGSFEntity obj) { ... }
 }

public enum Status { ... }
public enum Region { ... }

现在,这上周工作了。现在当我去保存任何实体时,我收到了这条消息:

 The following types may not be used as proxies:
 Core.Models.WeeklyGSFEntity: method IndexOf should be 'public/protected virtual' or 'protected internal virtual'
 Core.Models.WeeklyGSFEntity: method LastIndexOf should be 'public/protected virtual' or 'protected internal virtual'

正如你所看到的,没有IndexOf或LastIndexOf方法...... :)我试图覆盖它们但是它们不存在以便首先覆盖它们!

有什么想法吗?

更新第一个

所以我挖到IL并且没有方法IndexOfLastIndexOf的迹象。现在,在所有这一切发生之前,我做了创建一个关于冲突的新类,这个冲突有一个我的WeeklyGSFEntities的集合。现在这个集合将有IndexOfLastIndexOf方法,但是,我从项目中排除了映射和类......

1 个答案:

答案 0 :(得分:0)

好的,我没有从EqualityComparer<WeeklyGSFEntity>派生IEqualityComparer<WeeklyGSFEntity>而是实施{{1}}。 问题消失了......