【问题标题】:simple lookups in Data Access Layer, Business Layer or in UI?在数据访问层、业务层或 UI 中进行简单查找?
【发布时间】:2013-10-03 10:40:40
【问题描述】:

ASP .NET MVC4

第一课:

public class F61BPROD
{
    public int WPDOCO { get; set; }
    public string WPDCTO { get; set; }
    public string WPMCU { get; set; }
    public string WPLOCN { get; set; }
    public string WPDCT { get; set; }
    public int WPTRDJ { get; set; }
    public string WPKYPR { get; set; }
    public string WPLITM { get; set; }
    public decimal WPTRQT { get; set; }
    public string WPKYFN { get; set; }
    public string WPLOTN { get; set; }
    public string WPLRP1 { get; set; }
    public string WPLRP2 { get; set; }
    public string WPLRP3 { get; set; }
    public string WPLRP4 { get; set; }
    public string WPLRP5 { get; set; }
    public string WPLRP6 { get; set; }
    public string WPLRP7 { get; set; }
    public string WPLRP8 { get; set; }
    public string WPLRP9 { get; set; }
    public string WPLRP0 { get; set; }
    public string WPFLAG { get; set; }
    public string WPLOT1 { get; set; }
    public string WPLOT2 { get; set; }
}

对于 #1 类的属性之一,我需要获取 #2 类之一:

    public class JDEItemBasic
    {
        public int itm { get; set; }
        public string litm { get; set; }
        public string dsc { get; set; }
        public string dsce { get; set; }
        public string ean14 { get; set; }
        public string cc { get; set; }
        public string uom1 { get; set; }
        public string uom2 { get; set; }
        public int uom1ea { get; set; }
        public int bxuom1 { get; set; }
        public int uom1gr { get; set; }
}

有一个获取上述类的 DAL。我需要将这些类组合成一个具有上述类的大部分属性的新类。

我应该创建第三个班级并在 BLL 中完成这项工作吗?

或者我应该在获取它们之后使用 LINQ to Entities 在 UI 中执行它?

【问题讨论】:

    标签: asp.net-mvc linq-to-entities data-access-layer business-logic-layer


    【解决方案1】:

    我应该创建第三个班级并在 BLL 中完成这项工作吗?

    或者我应该在获取它们之后使用 LINQ to Entities 在 UI 中执行它?

    这取决于你需要这个类的地方。如果它是为了显示目的,那么它应该存在于 UI 中。在这种情况下,此类甚至还有一个名称:它被称为视图模型,是您的控制器操作在查询 DAL 层并将各种结果投影到此视图模型后可以传递给视图的内容。

    【讨论】:

    • 这个类是类#1 的“丰富”类。将项目信息添加到类 #1。我想在其他项目中使用它。所以我想我应该在我的 BLL 类中创建它?
    • 是的,如果您需要在其他项目中访问它,那么住在您的 BLL 中会很有意义。
    • 罗杰,谢谢。我会用你的逻辑更新我的问题。
    猜你喜欢
    • 2020-11-28
    • 2010-12-13
    • 2012-11-26
    • 1970-01-01
    • 2012-08-30
    • 2012-07-06
    • 2023-03-11
    • 2012-11-27
    • 1970-01-01
    相关资源
    最近更新 更多