public BaseRepository(MSSqlDBContext context) { if (context != null) { this.db = context; } }
public static List <T> Run <T>(this SqlStrModel sqlStrModel, MSSqlDBContext db) { DbContextSqlQueryCommand dbContextSqlQueryCommand = new DbContextSqlQueryCommand(); dbContextSqlQueryCommand.QueryType = "text"; dbContextSqlQueryCommand.Query = sqlStrModel.SqlStr; return(SelectDb <T>(dbContextSqlQueryCommand, db)); }
public static T Run <T>(this GetByIdModel sqlStrModel, MSSqlDBContext db) { DbContextSqlQueryCommand dbContextSqlQueryCommand = new DbContextSqlQueryCommand(); dbContextSqlQueryCommand.QueryType = "text"; dbContextSqlQueryCommand.Query = sqlStrModel.IdStr; return(SelectDb <T>(dbContextSqlQueryCommand, db).FirstOrDefault()); //string sql = string.Empty; }
public SysAreaService( IHttpRpcService _HttpRpcService, IQRCodeService _IQRCodeService, ILogService _LogService, IConfiguration _IConfiguration, ISysAreaRepository _ISysAreaRepository ) { httpRpcService = _HttpRpcService; qRCodeService = _IQRCodeService; logService = _LogService; configuration = _IConfiguration; sysAreaRepository = _ISysAreaRepository; db = sysAreaRepository.GetDb(); }
public static List <T> Run <T>(this CheckInfo checkInfo, MSSqlDBContext db, List <ErrorList> erolt, ref int DataCount) { //select * from PaasOLT_OrderCarClean order by Id offset((2 - 1) * 20) rows fetch next 20 rows only; //查询 string TsqlCountStr = "select COUNT(1) from " + checkInfo.tableName + " "; //条件 string strWhere = checkInfo.strWhere == null ? null : " where " + checkInfo.strWhere; //查询总数 DbContextSqlQueryCommand dbContextSqlQueryCommand = new DbContextSqlQueryCommand(); dbContextSqlQueryCommand.QueryType = "text"; dbContextSqlQueryCommand.Query = TsqlCountStr + strWhere; int DbRequest = (int)DbContextExtensions.QueryObject(new MSSqlDBContext(), new DbContextSqlQueryCommands { Sql = dbContextSqlQueryCommand }); DataCount = DbRequest; return(Run <T>(checkInfo, db, erolt)); }
public static List <T> SelectDb <T>(DbContextSqlQueryCommand dbContextSqlQueryCommand, MSSqlDBContext db) { var DbRequest = DbContextExtensions.Query <T>(db, new DbContextSqlQueryCommands { Sql = dbContextSqlQueryCommand }).ToList(); //string sql = string.Empty; return(DbRequest); }
public static List <T> Run <T>(this CheckInfo checkInfo, MSSqlDBContext db, List <ErrorList> erolt) { var dbContextSqlQueryCommand = TsqlFactory.Select(checkInfo); return(SelectDb <T>(dbContextSqlQueryCommand, db)); }
public SysAreaRepository(MSSqlDBContext db) : base(db) { }
static void Main(string[] args) { //try //{ var container = new RegisterByContainer().Container; //var unitOfWork = container.GetInstance<IUnitOfWork>(); while (true) { Console.WriteLine("Что желаете? '1' - миграция БД, '3' - тест, '4' - тест для Благовещения, '5' - XmlSerialization"); Console.WriteLine("'6' - test Esperinos"); ConsoleKeyInfo info = Console.ReadKey(); switch (info.KeyChar) { case '1': var ef = GetMSSqlUnitOfWork(); Migrate(ef); break; case '2': { var context = new SQLiteDBContext(@"FileName=data\SQLiteDB.db"); var sqlite = new UnitOfWork(context, new RepositoryFactory(context)); Migrate(sqlite); } break; case '3': ef = GetMSSqlUnitOfWork(); TestDate(ef); break; case '4': ef = GetMSSqlUnitOfWork(); TestBlagoveshenie(ef); break; case '5': TestXmlSrialization(); break; case '6': TestEsperinos(); break; } IUnitOfWork GetMSSqlUnitOfWork() { var context = new MSSqlDBContext(ConfigurationManager.ConnectionStrings["DBTypicon"].ConnectionString); return new UnitOfWork(context, new RepositoryFactory(context)); }; } //} //catch (Exception ex) //{ // Console.WriteLine(ex.ToString()); //} //FillDB(unitOfWork); //unitOfWork.Commit(); }