using Microsoft.Data.SqlClient; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Console; using Microsoft.Extensions.Logging.Debug; using Microsoft.Extensions.Options; using MySqlConnector; using Npgsql; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using WalkingTec.Mvvm.Core.Extensions; using WalkingTec.Mvvm.Core.Support.Json; namespace WalkingTec.Mvvm.Core { /// /// FrameworkContext /// public partial class FrameworkContext : EmptyContext, IDataContext { public DbSet BaseFrameworkMenus { get; set; } public DbSet BaseFunctionPrivileges { get; set; } public DbSet BaseDataPrivileges { get; set; } public DbSet BaseFileAttachments { get; set; } public DbSet BaseFrameworkGroups { get; set; } public DbSet BaseFrameworkRoles { get; set; } public DbSet BaseFrameworkUserRoles { get; set; } public DbSet BaseFrameworkUserGroups { get; set; } public DbSet BaseActionLogs { get; set; } public DbSet JobLogs { get; set; } public DbSet InterfaceLogs { get; set; } public DbSet FrameworkTenants { get; set; } /// /// FrameworkContext /// public FrameworkContext() : base() { } /// /// FrameworkContext /// /// public FrameworkContext(string cs) : base(cs) { } public FrameworkContext(string cs, DBTypeEnum dbtype, string version = null) : base(cs, dbtype, version) { } public FrameworkContext(CS cs) : base(cs) { } public FrameworkContext(DbContextOptions options) : base(options) { } /// /// OnModelCreating /// /// protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); //菜单和菜单权限的级联删除 //wtmtodo: 删除菜单同步删除页面权限 //modelBuilder.Entity().HasOne(x => x.MenuItem).WithMany(x => x.Privileges).HasForeignKey(x => x.MenuItemId).OnDelete(DeleteBehavior.Cascade); var allTypes = Utils.GetAllModels(); foreach (var item in allTypes) { if (typeof(TopBasePoco).IsAssignableFrom(item) && typeof(ISubFile).IsAssignableFrom(item) == false) { //将所有关联附件的外键设为不可级联删除 var pros = item.GetProperties().Where(x => x.PropertyType == typeof(FileAttachment)).ToList(); foreach (var filepro in pros) { var builder = typeof(ModelBuilder).GetMethod("Entity", Type.EmptyTypes).MakeGenericMethod(item).Invoke(modelBuilder, null) as EntityTypeBuilder; builder.HasOne(filepro.Name).WithMany().OnDelete(DeleteBehavior.Restrict); } } List list = new List(); ParameterExpression pe = Expression.Parameter(item); if (item.BaseType == null || item.BaseType.IsAbstract == true || (item.BaseType == typeof(TopBasePoco) || item.BaseType == typeof(BasePoco) || item.BaseType?.BaseType == typeof(TreePoco))) { if (typeof(IPersistPoco).IsAssignableFrom(item)) { var exp = Expression.Equal(Expression.Property(pe, "IsValid"), Expression.Constant(true)); list.Add(exp); } if (typeof(ITenant).IsAssignableFrom(item)) { var exp = Expression.Equal(Expression.Property(pe, "TenantCode"), Expression.PropertyOrField(Expression.Constant(this), "TenantCode")); list.Add(exp); } if (list.Count > 0) { var finalexp = list[0]; for (int i = 1; i < list.Count; i++) { finalexp = Expression.AndAlso(finalexp, list[i]); } var builder = typeof(ModelBuilder).GetMethod("Entity", Type.EmptyTypes).MakeGenericMethod(item).Invoke(modelBuilder, null) as EntityTypeBuilder; builder.HasQueryFilter(Expression.Lambda(finalexp, pe)); } } } } /// /// 数据初始化 /// /// /// /// 返回true表示需要进行初始化数据操作,返回false即数据库已经存在或不需要初始化数据 public async override Task DataInit(object allModules, bool IsSpa) { bool rv = await Database.EnsureCreatedAsync(); //判断是否存在初始数据 bool emptydb = false; try { emptydb = Set().Count() == 0 && Set().Count() == 0; } catch { } if (emptydb == true) { var AllModules = allModules as List; var roles = new FrameworkRole[] { new FrameworkRole{ ID = Guid.NewGuid(), RoleCode = "001", RoleName = CoreProgram._localizer?["Sys.Admin"], TenantCode=TenantCode}, new FrameworkRole{ ID = Guid.NewGuid(), RoleCode = "002", RoleName = CoreProgram._localizer?["_Admin.User"], TenantCode=TenantCode}, }; var adminRole = roles[0]; if (Set().Any() == false && TenantCode == null) { var systemManagement = GetFolderMenu("SystemManagement"); var logList = IsSpa ? GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1) : GetMenu(AllModules, "_Admin", "ActionLog", "Index", "MenuKey.ActionLog", 1); var userList = IsSpa ? GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2) : GetMenu(AllModules, "_Admin", "FrameworkUser", "Index", "MenuKey.UserManagement", 2); var roleList = IsSpa ? GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3) : GetMenu(AllModules, "_Admin", "FrameworkRole", "Index", "MenuKey.RoleManagement", 3); var groupList = IsSpa ? GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4) : GetMenu(AllModules, "_Admin", "FrameworkGroup", "Index", "MenuKey.GroupManagement", 4); var menuList = IsSpa ? GetMenu2(AllModules, "FrameworkMenu", "MenuKey.MenuMangement", 5) : GetMenu(AllModules, "_Admin", "FrameworkMenu", "Index", "MenuKey.MenuMangement", 5); var dpList = IsSpa ? GetMenu2(AllModules, "DataPrivilege", "MenuKey.DataPrivilege", 6) : GetMenu(AllModules, "_Admin", "DataPrivilege", "Index", "MenuKey.DataPrivilege", 6); var tenantList = IsSpa ? GetMenu2(AllModules, "FrameworkTenant", "MenuKey.FrameworkTenant", 6) : GetMenu(AllModules, "_Admin", "FrameworkTenant", "Index", "MenuKey.FrameworkTenant", 7); if (logList != null) { var menus = new FrameworkMenu[] { logList, userList, roleList, groupList, menuList, dpList, tenantList }; foreach (var item in menus) { if (item != null) { systemManagement.Children.Add(item); } } Set().Add(systemManagement); Set().AddRange(systemManagement.FlatTree().Select(x => new FunctionPrivilege { RoleCode = "001", MenuItemId = x.ID, Allowed = true })); if (IsSpa == false) { systemManagement.Icon = "layui-icon layui-icon-set"; logList?.SetPropertyValue("Icon", "layui-icon layui-icon-form"); userList?.SetPropertyValue("Icon", "layui-icon layui-icon-friends"); roleList?.SetPropertyValue("Icon", "layui-icon layui-icon-user"); groupList?.SetPropertyValue("Icon", "layui-icon layui-icon-group"); menuList?.SetPropertyValue("Icon", "layui-icon layui-icon-menu-fill"); dpList?.SetPropertyValue("Icon", "layui-icon layui-icon-auz"); tenantList?.SetPropertyValue("Icon", " layui-icon layui-icon-share"); var apifolder = GetFolderMenu("Api"); apifolder.ShowOnMenu = false; apifolder.DisplayOrder = 100; var logList2 = GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1); var userList2 = GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2); var roleList2 = GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3); var groupList2 = GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4); var menuList2 = GetMenu2(AllModules, "FrameworkMenu", "MenuKey.MenuMangement", 5); var dpList2 = GetMenu2(AllModules, "DataPrivilege", "MenuKey.DataPrivilege", 6); var tenantList2 = GetMenu2(AllModules, "FrameworkTenant", "MenuKey.FrameworkTenant", 7); var apis = new FrameworkMenu[] { logList2, userList2, roleList2, groupList2, menuList2, dpList2, tenantList2 }; //apis.ToList().ForEach(x => { x.ShowOnMenu = false;x.PageName += $"({Program._localizer["BuildinApi"]})"; }); foreach (var item in apis) { if (item != null) { item.ModuleName += "Api"; item.ShowOnMenu = false; apifolder.Children.Add(item); } } Set().Add(apifolder); Set().AddRange(apifolder.FlatTree().Select(x => new FunctionPrivilege { RoleCode = "001", MenuItemId = x.ID, Allowed = true })); } else { systemManagement.Icon = " _wtmicon _wtmicon-icon_shezhi"; logList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-chaxun"); userList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-zhanghaoquanxianguanli"); roleList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-quanxianshenpi"); groupList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-zuzhiqunzu"); menuList?.SetPropertyValue("Icon", " _wtmicon _wtmicon--lumingpai"); dpList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-anquan"); tenantList?.SetPropertyValue("Icon", " _wtmicon _wtmicon-fenxiangfangshi"); } } } Set().AddRange(roles); await SaveChangesAsync(); } return rv; } private FrameworkMenu GetFolderMenu(string FolderText, bool isShowOnMenu = true, bool isInherite = false) { FrameworkMenu menu = new FrameworkMenu { PageName = "MenuKey." + FolderText, Children = new List(), ShowOnMenu = isShowOnMenu, IsInside = true, FolderOnly = true, IsPublic = false, TenantAllowed = true, DisplayOrder = 1 }; return menu; } private FrameworkMenu GetMenu(List allModules, string areaName, string controllerName, string actionName, string pageKey, int displayOrder) { var acts = allModules.Where(x => x.ClassName == controllerName && (areaName == null || x.Area?.Prefix?.ToLower() == areaName.ToLower())).SelectMany(x => x.Actions).ToList(); var act = acts.Where(x => x.MethodName == actionName).SingleOrDefault(); var rest = acts.Where(x => x.MethodName != actionName && x.IgnorePrivillege == false).ToList(); bool allowtenant = controllerName != "FrameworkMenu"; FrameworkMenu menu = GetMenuFromAction(act, true, displayOrder, allowtenant); if (act?.Module?.IsApi == true) { menu.ModuleName += "Api"; } if (menu != null) { menu.PageName = pageKey; for (int i = 0; i < rest.Count; i++) { if (rest[i] != null) { var sub = GetMenuFromAction(rest[i], false, (i + 1), allowtenant); sub.PageName = pageKey; if (rest[i].Module.IsApi == true) { sub.ModuleName += "Api"; } menu.Children.Add(sub); } } } return menu; } private FrameworkMenu GetMenu2(List allModules, string controllerName, string pageKey, int displayOrder) { bool allowtenant = controllerName != "FrameworkMenu"; var acts = allModules.Where(x => (x.FullName == $"WalkingTec.Mvvm.Admin.Api,{controllerName}") && x.IsApi == true).SelectMany(x => x.Actions).ToList(); var rest = acts.Where(x => x.IgnorePrivillege == false).ToList(); SimpleAction act = null; if (acts.Count > 0) { act = acts[0]; } FrameworkMenu menu = GetMenuFromAction(act, true, displayOrder, allowtenant); if (menu != null) { menu.PageName = pageKey; menu.Url = "/" + acts[0].Module.ClassName.ToLower(); menu.ActionName = "MainPage"; menu.ClassName = acts[0].Module.FullName; menu.MethodName = null; for (int i = 0; i < rest.Count; i++) { if (rest[i] != null) { var sub = GetMenuFromAction(rest[i], false, (i + 1), allowtenant); sub.PageName = pageKey; menu.Children.Add(sub); } } } return menu; } private FrameworkMenu GetMenuFromAction(SimpleAction act, bool isMainLink, int displayOrder = 1, bool allowtenant = true) { if (act == null) { return null; } FrameworkMenu menu = new FrameworkMenu { //ActionId = act.ID, //ModuleId = act.ModuleId, ClassName = act.Module.FullName, MethodName = act.MethodName, Url = act.Url, ShowOnMenu = isMainLink, FolderOnly = false, Children = new List(), IsPublic = false, IsInside = true, DisplayOrder = displayOrder, TenantAllowed = allowtenant }; if (isMainLink) { menu.ModuleName = act.Module.ModuleName; menu.ActionName = act.ActionDes?.Description ?? act.ActionName; menu.MethodName = null; } else { menu.ModuleName = act.Module.ModuleName; menu.ActionName = act.ActionDes?.Description ?? act.ActionName; } return menu; } } public partial class EmptyContext : DbContext, IDataContext { private ILoggerFactory _loggerFactory; /// /// Commited /// public bool Commited { get; set; } /// /// IsFake /// public bool IsFake { get; set; } private string _tenantCode; public string TenantCode { get { return _tenantCode; } } public bool IsDebug { get; set; } /// /// CSName /// public string CSName { get; set; } public DBTypeEnum DBType { get; set; } public string Version { get; set; } public CS ConnectionString { get; set; } /// /// FrameworkContext /// public EmptyContext() { CSName = "default"; DBType = DBTypeEnum.SqlServer; } /// /// FrameworkContext /// /// public EmptyContext(string cs) { CSName = cs; DBType = DBTypeEnum.SqlServer; } public EmptyContext(string cs, DBTypeEnum dbtype, string version = null) { CSName = cs; DBType = dbtype; Version = version; } public EmptyContext(CS cs) { CSName = cs.Value; DBType = cs.DbType ?? DBTypeEnum.SqlServer; Version = cs.Version; ConnectionString = cs; } public EmptyContext(DbContextOptions options) : base(options) { } public IDataContext CreateNew() { if (ConnectionString != null) { return (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(CS) }).Invoke(new object[] { ConnectionString }); ; } else { return (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(string), typeof(DBTypeEnum), typeof(string) }).Invoke(new object[] { CSName, DBType, Version }); } } public IDataContext ReCreate() { if (this?.Database?.CurrentTransaction != null) { return this; } else { IDataContext rv = null; if (ConnectionString != null) { rv = (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(CS) }).Invoke(new object[] { ConnectionString }); ; } else { rv =(IDataContext)this.GetType().GetConstructor(new Type[] { typeof(string), typeof(DBTypeEnum) }).Invoke(new object[] { CSName, DBType }); } rv.SetTenantCode(this.TenantCode); return rv; } } /// /// 将一个实体设为填加状态 /// /// 实体 public void AddEntity(T entity) where T : TopBasePoco { this.Entry(entity).State = EntityState.Added; } /// /// 将一个实体设为修改状态 /// /// 实体 public void UpdateEntity(T entity) where T : TopBasePoco { this.Entry(entity).State = EntityState.Modified; } /// /// 将一个实体的某个字段设为修改状态,用于只更新个别字段的情况 /// /// 实体类 /// 实体 /// 要设定为修改状态的字段 public void UpdateProperty(T entity, Expression> fieldExp) where T : TopBasePoco { var set = this.Set(); if (set.Local.AsQueryable().CheckID(entity.GetID()).FirstOrDefault() == null) { set.Attach(entity); } this.Entry(entity).Property(fieldExp).IsModified = true; } /// /// UpdateProperty /// /// /// /// public void UpdateProperty(T entity, string fieldName) where T : TopBasePoco { var set = this.Set(); if (set.Local.AsQueryable().CheckID(entity.GetID()).FirstOrDefault() == null) { set.Attach(entity); } this.Entry(entity).Property(fieldName).IsModified = true; } /// /// 将一个实体设定为删除状态 /// /// 实体 public void DeleteEntity(T entity) where T : TopBasePoco { var set = this.Set(); var exist = set.Local.AsQueryable().CheckID(entity.GetID()).FirstOrDefault(); if (exist == null) { set.Attach(entity); set.Remove(entity); } else { set.Remove(exist); } } /// /// CascadeDelete /// /// /// public void CascadeDelete(T entity) where T : TreePoco { if (entity != null && entity.ID != Guid.Empty) { var set = this.Set(); var entities = set.Where(x => x.ParentId == entity.ID).ToList(); if (entities.Count > 0) { foreach (var item in entities) { CascadeDelete(item); } } DeleteEntity(entity); } } /// /// GetCoreType /// /// /// public Type GetCoreType(Type t) { if (t != null && t.IsNullable()) { if (!t.GetTypeInfo().IsValueType) { return t; } else { if ("DateTime".Equals(t.GenericTypeArguments[0].Name)) { return typeof(string); } return Nullable.GetUnderlyingType(t); } } else { if ("DateTime".Equals(t.Name)) { return typeof(string); } return t; } } /// /// OnModelCreating /// /// protected override void OnModelCreating(ModelBuilder modelBuilder) { if (DBType == DBTypeEnum.Oracle) { modelBuilder.Model.SetMaxIdentifierLength(30); } } /// /// OnConfiguring /// /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { switch (DBType) { case DBTypeEnum.SqlServer: optionsBuilder.UseSqlServer(CSName); break; case DBTypeEnum.MySql: ServerVersion sv = null; if (string.IsNullOrEmpty(Version) == false) { ServerVersion.TryParse(Version, out sv); } if (sv == null) { sv = ServerVersion.AutoDetect(CSName); } optionsBuilder.UseMySql(CSName, sv); break; case DBTypeEnum.PgSql: optionsBuilder.UseNpgsql(CSName); break; case DBTypeEnum.Memory: optionsBuilder.UseInMemoryDatabase(CSName); break; case DBTypeEnum.SQLite: optionsBuilder.UseSqlite(CSName); break; //case DBTypeEnum.DaMeng: // optionsBuilder.UseDm(CSName); // break; case DBTypeEnum.Oracle: optionsBuilder.UseOracle(CSName, option => { if (string.IsNullOrEmpty(Version) == false) { option.UseOracleSQLCompatibility(Version); } else { option.UseOracleSQLCompatibility("11"); } }); break; default: break; } if (IsDebug == true) { optionsBuilder.EnableDetailedErrors(); optionsBuilder.EnableSensitiveDataLogging(); if (_loggerFactory != null) { optionsBuilder.UseLoggerFactory(_loggerFactory); } } base.OnConfiguring(optionsBuilder); } public void SetLoggerFactory(ILoggerFactory factory) { this._loggerFactory = factory; } public void SetTenantCode(string code) { this._tenantCode = code; } /// /// 数据初始化 /// /// /// /// 返回true表示需要进行初始化数据操作,返回false即数据库已经存在或不需要初始化数据 public async virtual Task DataInit(object allModules, bool IsSpa) { bool rv = await Database.EnsureCreatedAsync(); return rv; } #region 执行存储过程返回datatable /// /// 执行存储过程,返回datatable结果集 /// /// 存储过程名称 /// 存储过程参数 /// public DataTable RunSP(string command, params object[] paras) { return Run(command, CommandType.StoredProcedure, paras); } #endregion public IEnumerable RunSP(string command, params object[] paras) { return Run(command, CommandType.StoredProcedure, paras); } #region 执行Sql语句,返回datatable public DataTable RunSQL(string sql, params object[] paras) { return Run(sql, CommandType.Text, paras); } #endregion public IEnumerable RunSQL(string sql, params object[] paras) { return Run(sql, CommandType.Text, paras); } #region 执行存储过程或Sql语句返回DataTable /// /// 执行存储过程或Sql语句返回DataTable /// /// 存储过程名称或Sql语句 /// 命令类型 /// 参数 /// public DataTable Run(string sql, CommandType commandType, params object[] paras) { DataTable table = new DataTable(); var connection = this.Database.GetDbConnection(); var isClosed = connection.State == ConnectionState.Closed; if (isClosed) { connection.Open(); } using (var command = connection.CreateCommand()) { command.CommandText = sql; command.CommandTimeout = 2400; command.CommandType = commandType; if (this.Database.CurrentTransaction != null) { command.Transaction = this.Database.CurrentTransaction.GetDbTransaction(); } if (paras != null) { foreach (var param in paras) command.Parameters.Add(param); } using (var reader = command.ExecuteReader()) { table.Load(reader); } } if (isClosed) { connection.Close(); } return table; } #endregion public IEnumerable Run(string sql, CommandType commandType, params object[] paras) { IEnumerable entityList = new List(); DataTable dt = Run(sql, commandType, paras); entityList = EntityHelper.GetEntityList(dt); return entityList; } public object CreateCommandParameter(string name, object value, ParameterDirection dir) { object rv = null; switch (this.DBType) { case DBTypeEnum.SqlServer: rv = new SqlParameter(name, value) { Direction = dir }; break; case DBTypeEnum.MySql: rv = new MySqlParameter(name, value) { Direction = dir }; break; case DBTypeEnum.PgSql: rv = new NpgsqlParameter(name, value) { Direction = dir }; break; case DBTypeEnum.SQLite: rv = new SqliteParameter(name, value) { Direction = dir }; break; case DBTypeEnum.Oracle: //rv = new OracleParameter(name, value) { Direction = dir }; break; } return rv; } } public class NullContext : IDataContext { public string TenantCode { get; } public bool IsFake { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public IModel Model => throw new NotImplementedException(); public DatabaseFacade Database => throw new NotImplementedException(); public string CSName { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public DBTypeEnum DBType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public bool IsDebug { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public void AddEntity(T entity) where T : TopBasePoco { throw new NotImplementedException(); } public void CascadeDelete(T entity) where T : TreePoco { throw new NotImplementedException(); } public object CreateCommandParameter(string name, object value, ParameterDirection dir) { throw new NotImplementedException(); } public IDataContext CreateNew() { throw new NotImplementedException(); } public Task DataInit(object AllModel, bool IsSpa) { throw new NotImplementedException(); } public void DeleteEntity(T entity) where T : TopBasePoco { throw new NotImplementedException(); } public void Dispose() { } public IDataContext ReCreate() { throw new NotImplementedException(); } public DataTable Run(string sql, CommandType commandType, params object[] paras) { throw new NotImplementedException(); } public IEnumerable Run(string sql, CommandType commandType, params object[] paras) { throw new NotImplementedException(); } public DataTable RunSP(string command, params object[] paras) { throw new NotImplementedException(); } public IEnumerable RunSP(string command, params object[] paras) { throw new NotImplementedException(); } public DataTable RunSQL(string command, params object[] paras) { throw new NotImplementedException(); } public IEnumerable RunSQL(string sql, params object[] paras) { throw new NotImplementedException(); } public int SaveChanges() { throw new NotImplementedException(); } public int SaveChanges(bool acceptAllChangesOnSuccess) { throw new NotImplementedException(); } public Task SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } public Task SaveChangesAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } public DbSet Set() where T : class { throw new NotImplementedException(); } public void SetTenantCode(string code) { throw new NotImplementedException(); } public void SetLoggerFactory(ILoggerFactory factory) { throw new NotImplementedException(); } public void UpdateEntity(T entity) where T : TopBasePoco { throw new NotImplementedException(); } public void UpdateProperty(T entity, Expression> fieldExp) where T : TopBasePoco { throw new NotImplementedException(); } public void UpdateProperty(T entity, string fieldName) where T : TopBasePoco { throw new NotImplementedException(); } } }