Esempio n. 1
0
        public static List <T> Select <T>(Action <SelectFields <T> > selectFields, Expression <Func <T, bool> > where)
        {
            SelectFields <T> select = new SelectFields <T>();

            selectFields.Invoke(select);
            SqlModel sqlSelect = select.GetSqlParam();
            SqlModel sqlWhere  = GernericMapper <T> .GetWhereSql(where);

            string sql = $"select {sqlSelect.SqlText} From [{GernericMapper<T>.GetTableName()}] where {sqlWhere.SqlText}";
            string connectionString = "Data Source=HGH1-DEV01.qqtoa.com;Initial Catalog=CpsMain;Persist Security Info=True;User ID=ReadOnlyUser;Password=ReadOnly@1234";

            using (IDbConnection conn = new SqlConnection(connectionString))
            {
                DateTime dt1 = DateTime.Now;
                conn.Open();
                var command = conn.CreateCommand();
                command.CommandText = sql;
                foreach (var pair in sqlWhere.Parameters)
                {
                    command.Parameters.Add(new SqlParameter(pair.Key, pair.Value));
                }
                return(command.ExecuteReader().TransformTo <T>());
            }
        }
Esempio n. 2
0
 public static void Update <T>(this T t, SelectFields <T> selectFields, Expression <Func <T, bool> > where)
 {
 }