예제 #1
0
        public int Update(TEntity entity)
        {
            //UPDATE Customers SET Col1=@Col1,Col2=@Col2,Col3=@Col3;
            var props = _type.GetProperties();
            List <SqlParameter> sqlParameters = new List <SqlParameter>();

            foreach (var prop in props)
            {
                sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity))));
            }

            return(_sqlHelperW.ExecuteNoQuery(_updateText, sqlParameters.ToArray()));
        }
예제 #2
0
        public object InsertBackRecord(TEntity entity)
        {
            //INSERT INTO Customers {col1,col2,clo3} VALUES(@Col1,@Col2,@Col3);

            var props = _type.GetProperties().Where(m => !m.Name.Equals("Id"));
            //var strCols = GetColumns().Where(m => !m.Equals("Id"));
            List <SqlParameter> sqlParameters = new List <SqlParameter>();

            foreach (var prop in props)
            {
                sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity))));
            }

            return(_sqlHelperW.ExecuteScalar(_insertBackText, sqlParameters.ToArray()));
        }
예제 #3
0
        public int Insert(TEntity entity)
        {
            //INSERT INTO Customers {col1,col2,clo3} VALUES(@Col1,@Col2,@Col3);
            IEnumerable <PropertyInfo> props = _type.GetProperties().Where(m => !m.Name.Equals("Id"));
            //IEnumerable<string> strCols = GetColumns().Where(m => !m.Equals("Id"));

            List <SqlParameter> sqlParameters = new List <SqlParameter>();

            foreach (var prop in props)
            {
                sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity))));
            }

            return(_sqlHelperW.ExecuteNoQuery(_insertText, sqlParameters.ToArray()));
        }