Go to my github

LCLFramework框架之开发约束

Entity编写

1:所有的实体类都必须继承DomainEntity
2:所有的表都必须有 ID
3:所有表的关系字段必须是ID
[Serializable]
public class User: DomainEntity
{
    //public string Name { set; get; }
}
具体的Entity关系编写请查看LCLFramework实体关系
服务编写:

[Serializable]
pulic class UserService:FlowService
 
}
 扩展仓库:

public interface IUserRepository : IRepository<User> 
{
 
}
public class UserRepository : EntityFrameworkRepository<User>, IUserRepository
 {
      public UserRepository(IRepositoryContext context)  : base(context) 
        {
       
        }
        public User GetBy(string username, string password)
        {
            var users = base.Get(e => e.Code == username && e.Password == password);
            if (users.Count() > 0)
            {
                return users.ToList()[0];
            }
            return null;
        }
}
插件编写:

//表示当前程序集是一个插件
public class LibraryPlugin : LCLPlugin
{
   public override void Initialize(IApp app)
   {
      //在这里初始化插件本身
      /*
        初始化IOC:
        ServiceLocator.Instance.Register<IRepository<Org>, EntityFrameworkRepository<Org>>();
        初始化菜单:
        CommonModel.Modules.AddRoot(new MvcModuleMeta
         {
                Label = "区域管理",
                Bundle = this,
                Children =
                {
                    new MvcModuleMeta{Label = "小区管理", 
                       EntityType=typeof(VillageController),    //查询需要权限控制的action                        CustomUI="/UIShell.AreaManagementPlugin/Village/Index"},
                }
            });
     */
  }
}
posted @   峡谷少爷  阅读(308)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
历史上的今天:
2012-09-02 关于SVN提交强制加入注释
2012-09-02 C# WinForm 技巧五:WinForm界面生成
点击右上角即可分享
微信分享提示