public ActionResult Update(string val) { if (Request.IsAjaxRequest()) { string output = "Данный цвет зарегистрирован ранее"; string connection = WebConfigurationManager.AppSettings["sqlConnection"]; //Должна быть возможность создать одно сеодинение к бд и использовать его в дальнейшем, а создать его на каждый чих DbLink _dbLink = new DbLink(Fabricate.CreateConnection(connection, ConnectionType.SqlConnection)); if (!Colour.Exist(_dbLink, val)) { if (Colour.Insert(_dbLink, val)) { output = "Цвет успешно зарегистрирован"; } else { output = "Значение не удалось добавить"; } } //вернем только часть страницы return(PartialView("_UpdatePartial", output)); } //Если будет отключен js, то перейдем полностью на новую форму return(View(val)); }
public void TestConnection() { var connection = ConfigurationManager.AppSettings.Get("postgre"); var postgre = Fabricate.CreateConnection(connection, ConnectionType.Npgsql); DbLink dbLink = new DbLink(postgre); var t = dbLink.GetConnection(); }
public void UsingWithDapperAndFabricate() { string connection = "Host = localhost; Username =postgres; Password =roman; Database =MIR"; var dbConnection = Fabricate.CreateConnection(connection, ConnectionType.Npgsql); DbLink dbLink = new DbLink(dbConnection); var t = dbLink.GetConnection().Query <DataSource>("select * from data_source").First(); Console.WriteLine(t.ident); }
public int Count(Expression <Func <TModel, TForeignModel, bool> > whereSelector, string include = "", bool isAll = true) { var arr = MySQLUtility.ExecuteParm(whereSelector, include); return(Convert.ToInt32(Fabricate.GetTable(CommandType.Text, CreateSql(isAll ? SqlType.Count_MySQL : SqlType.CountDetail, arr.Item4, arr.Item1.Remove(arr.Item1.Length - 1), arr.Item2)).Rows[0][0])); }
public IEnumerable <TModel> GetList(Expression <Func <TModel, TForeignModel, bool> > whereSelector, int pageSize = 20, int pageNum = 1, string include = "", OrderByEntity orderBy = null) { var arr = MySQLUtility.ExecuteParm(whereSelector, include); return(Fabricate.GetListByTable <TModel>(CommandType.Text, CreateSql(SqlType.GetPage_MySQL, arr.Item4, arr.Item1.Remove(arr.Item1.Length - 1), arr.Item2, orderBy, pageSize, pageNum), arr.Item5, include, arr.Item3.ToArray())); }
public int Count(Expression <Func <TModel, TForeignModel, bool> > whereSelector, string include = "", bool isAll = true) { var paramModel = MySQLUtility.ExecuteParm(whereSelector, include); return(Convert.ToInt32(Fabricate.GetTable(CommandType.Text, CreateSql(isAll ? SqlType.Count_MySQL : SqlType.CountDetail, paramModel.TableName, paramModel.ColumnName, paramModel.WhereSQL)).Rows[0][0])); }
public IEnumerable <TModel> GetList(Expression <Func <TModel, TForeignModel, bool> > whereSelector, int pageSize = 20, int pageNum = 1, string include = "", IEnumerable <OrderByEntity> orderBy = null) { var paramModel = MySQLUtility.ExecuteParm(whereSelector, include); return(Fabricate.GetListByTable <TModel>(CommandType.Text, CreateSql(SqlType.GetPageOneToOne_MySQL, paramModel.TableName, paramModel.ColumnName, paramModel.WhereSQL, orderBy, pageSize, pageNum), paramModel.ListTableMap, include, paramModel.ListSqlParams.ToArray())); }
public IEnumerable <TModel> GetList(Expression <Func <TModel, bool> > mainWhereSelector, Expression <Func <TForeignModel, bool> > joinWhereSelector, string include = "", IEnumerable <OrderByEntity> orderBy = null) { var paramModel = MySQLUtility.ExecuteParm(mainWhereSelector, joinWhereSelector, include); return(Fabricate.GetListByTable <TModel>(CommandType.Text, CreateSql(SqlType.Get, paramModel.TableName, paramModel.ColumnName, paramModel.WhereSQL, orderBy), paramModel.ListTableMap, include, paramModel.ListSqlParams.ToArray())); }