1

下面有一个更新

我有以下类派生自我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方法,但是,我从项目中排除了映射和类......

4

1 回答 1

0

好的,而不是从EqualityComparer<WeeklyGSFEntity>我实现的派生IEqualityComparer<WeeklyGSFEntity>。问题消失了...

于 2013-02-01T08:54:56.607 回答