LinqToSql and abstract base classes

前端 未结 4 452
[愿得一人]
[愿得一人] 2021-01-18 11:59

I have some linq entities that inherit something like this:

public abstract class EntityBase { public int Identifier { get; } }

public interface IDeviceEnti         


        
4条回答
  •  悲&欢浪女
    2021-01-18 12:27

    Wow, looks like for once I may be able to one-up @MarcGravell!

    I had the same problem, then I discovered this answer, which solved the problem for me!

    In your case, you would say:

    return unitOfWork.GetRepository().Select(x => x).FindOne(x => x.DeviceId == evt.DeviceId);
    

    and Bob's your uncle!

提交回复
热议问题