【问题标题】:How should I use LINQ with UnitOfWork我应该如何将 LINQ 与 UnitOfWork 一起使用
【发布时间】:2020-03-27 19:53:56
【问题描述】:

我想获取一些数据

 var res = ToBllEntity(from person in UnitOfWork.Person where person.id == id select person);

但这是不正确的。 UnitOfWork.Person 出现错误“找不到位置”。我该如何解决?

【问题讨论】:

    标签: c# .net asp.net-core entity-framework-core


    【解决方案1】:

    添加 Linq 命名空间?

    添加到文件顶部:

    using System.Linq;
    

    【讨论】:

    • 我在几个类中做过,很烂:服务类(tis 类中的这段代码)、Repository 类、IUnit OfWork 接口和 UnitOfWork 类。这是行不通的
    • 它是例如工作,但我不想使用方法,我只需要 linq ______________________ return ToBllEntity(UnitOfWork.RankingOfFriend.GetAll().Where(s => s.Id == id) );
    • 更详细的错误判别。 ___________找不到源类型“IGenericRepository ”的查询模板的实现。找不到“哪里”。
    猜你喜欢
    • 2019-05-31
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 2023-03-22
    • 2012-01-31
    • 1970-01-01
    • 2021-05-05
    相关资源
    最近更新 更多