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"},
                }
            });
     */
  }
}
原文地址:https://www.cnblogs.com/luomingui/p/5832505.html