C# Code()。你可能想先看看这些。但这绝对是正确的做法。只要用自己的方法重写Equals和GetHashCode方法。@Tony我对你说的这些不熟悉。你的意思是我应该在dbcontext中重写该方法吗?你重写了Equals()和GetHashCode()了
C# Code()。你可能想先看看这些。但这绝对是正确的做法。只要用自己的方法重写Equals和GetHashCode方法。@Tony我对你说的这些不熟悉。你的意思是我应该在dbcontext中重写该方法吗?你重写了Equals()和GetHashCode()了,c#,entity-framework,lambda,except,C#,Entity Framework,Lambda,Except,Code()。你可能想先看看这些。但这绝对是正确的做法。只要用自己的方法重写Equals和GetHashCode方法。@Tony我对你说的这些不熟悉。你的意思是我应该在dbcontext中重写该方法吗?你重写了Equals()和GetHashCode()了吗在协助中?@flindeberg否我不知道覆盖等于()和GetHashCode()可能有点棘手。你可能想先看看这些。但这绝对是正确的方法。让我试试这个。谢谢,我应该在辅助类中实现这个。你能给我一些关于GetHashCode的详细信息吗?@EA
Code()。你可能想先看看这些。但这绝对是正确的做法。只要用自己的方法重写
Equals
和GetHashCode
方法。@Tony我对你说的这些不熟悉。你的意思是我应该在dbcontext中重写该方法吗?你重写了Equals()
和GetHashCode()了吗
在协助中
?@flindeberg否我不知道覆盖等于()
和GetHashCode()
可能有点棘手。你可能想先看看这些。但这绝对是正确的方法。让我试试这个。谢谢,我应该在辅助类中实现这个。你能给我一些关于GetHashCode的详细信息吗?@EA这对你应该很有用:。让我试试。谢谢,我应该在辅助类中实现此功能。您能给我一些有关GetHashCode的详细信息吗?@EA这应该对您有用:。让我试试。谢谢,我应该在辅助类中实现此功能。您能给我一些有关GetHashCode的详细信息吗?@EA这应该对您有用:。让我试试。谢谢,我应该在辅助类中实现它。您能给我一些关于GetHashCode的详细信息吗?@EA这对您应该很有用:。
public partial class Assistance
{
public int Id { get; set; }
public string AssistanceName { get; set; }
public string AssistanceTell { get; set; }
}
List<Assistance> assistanceWithoutExpert;
AssistanceJurorRepository assistanceJurorRepository = new AssistanceJurorRepository();
List<Assistance> assistancesWithExpert = assistanceJurorRepository.FindBy(i => i.User.Permission == "Assistance").Select(i => i.Assistance).ToList();
List<Assistance> AllAssitance = GetAll().ToList();
assistanceWithoutExpert = AllAssitance.Except(assistancesWithExpert).ToList();
return assistanceWithoutExpert;
public override int GetHashCode() {
return Id.GetHashCode();
}
public override bool Equals(obj otherInstance) {
return (otherInstance is Assistence) && ((Assistence)otherInstance).Id == Id;
}
public class AssistanceComparer: IEqualityComparer<Assistance>
{
public bool Equals(Assistance x, Assistance y)
{
return x.ID == y.ID;
}
public int GetHashCode(Assistance assistance)
{
return assistance.ID.GetHashCode();
}
}
assistanceWithoutExpert = AllAssitance.Except(assistancesWithExpert, new AssistanceComparer()).ToList();