跨业务逻辑层正确设置类访问器?

发布于 2024-10-17 11:34:08 字数 939 浏览 5 评论 0原文

我的业务逻辑层中有几个类(一些示例);

Atomic.Core.BLL.Client Atomic.Core.BLL.Airport Atomic.Core.BLL.Airline

在每个类上设置访问器时,我有时想引用 BLL 中的对象(因为它们是相互链接的),但我想高效地做到这一点,而且还可以使用最佳实践。

我想做这样的事情:

using System;
using System.Data;
//removed for brevity

namespace Atomic.Core.BLL.Airport
{
    public class Airport
    {
        private int airport_id = 0;
        public int AirportId
        {
            get { return airport_id; }
            set { airport_id = value; }
        }
        private Airline airline = null;
        public Airline Airline
        {
            get { return airline; }
            set { airline = value; }
        }
    }
}

Visual Studio 说我的 AirlineObject 是一个用作类型的命名空间,我完全理解这一点,那么我可以将 Airline 添加到“使用”列表中并简写它吗?我该怎么做? 使用 Atomic.Core.BLL.Airline 作为航空公司?我不记得了!另外,我是否错过了重点,我是否应该重新思考我想要做什么?

帮助(一如既往)表示赞赏。

I have several classes within my business logic layer (some examples);

Atomic.Core.BLL.Client
Atomic.Core.BLL.Airport
Atomic.Core.BLL.Airline

When setting up the accessors on each class, I want to sometimes refer to objects within the BLL (as they are interlinked), but I want to do it efficiently and moreover with best practice.

I want to do something like this:

using System;
using System.Data;
//removed for brevity

namespace Atomic.Core.BLL.Airport
{
    public class Airport
    {
        private int airport_id = 0;
        public int AirportId
        {
            get { return airport_id; }
            set { airport_id = value; }
        }
        private Airline airline = null;
        public Airline Airline
        {
            get { return airline; }
            set { airline = value; }
        }
    }
}

Visual Studio says that my AirlineObject is a namespace being used as a type, which I totally understand, so can I add Airline to the Using list and shorthand it? How do I do that? using Atomic.Core.BLL.Airline as Airline? I can't remember! Also, am I missing the point here and should I re-think what I am trying to do?

Help (as always) appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

○愚か者の日 2024-10-24 11:34:08

使用航空公司= Atomic.Core.BLL.Airline;

using Airline = Atomic.Core.BLL.Airline;

温柔少女心 2024-10-24 11:34:08

我不会将所有 BLL 类都放在自己的命名空间中。将它们全部转储到 Atomic.Core.BLL 中,或者如果您需要更具体,则将它们转储到 Atomic.Core.BLL.AiportLogic 的一个小节中。

I wouldn't have all BLL classes in their own namespace. Dump them all into Atomic.Core.BLL, or a subsection - Atomic.Core.BLL.AiportLogic - if you need to be more specific.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文