Beispiel #1
0
        public int Delete <T>(object[] propertyValue)
        {
            int           num3;
            string        name    = typeof(T).Name;
            string        str2    = DatabaseCommon.GetKeyField <T>().ToString();
            StringBuilder builder = new StringBuilder("DELETE FROM " + name + " WHERE " + str2 + " IN (");

            try
            {
                IList <DbParameter> source = new List <DbParameter>();
                int    index = 0;
                string str3  = DbHelper.DbParmChar + "ID" + index;
                for (int i = 0; i < (propertyValue.Length - 1); i++)
                {
                    object obj2 = propertyValue[i];
                    str3 = DbHelper.DbParmChar + "ID" + index;
                    builder.Append(str3).Append(",");
                    source.Add(DbFactory.CreateDbParameter(str3, obj2));
                    index++;
                }
                str3 = DbHelper.DbParmChar + "ID" + index;
                builder.Append(str3);
                source.Add(DbFactory.CreateDbParameter(str3, propertyValue[index]));
                builder.Append(")");
                num3 = DbHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), source.ToArray <DbParameter>());
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(num3);
        }
Beispiel #2
0
        public int Delete <T>(object propertyValue)
        {
            string              name    = typeof(T).Name;
            string              pkName  = DatabaseCommon.GetKeyField <T>().ToString();
            StringBuilder       builder = DatabaseCommon.DeleteSql(name, pkName);
            IList <DbParameter> source  = new List <DbParameter> {
                DbFactory.CreateDbParameter(DbHelper.DbParmChar + pkName, propertyValue)
            };

            return(DbHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), source.ToArray <DbParameter>()));
        }
Beispiel #3
0
        public T FindEntity <T>(object propertyValue) where T : new()
        {
            string        str     = DatabaseCommon.GetKeyField <T>().ToString();
            StringBuilder builder = DatabaseCommon.SelectSql <T>();

            builder.Append(" AND ").Append(str).Append("=").Append(DbHelper.DbParmChar + str);
            IList <DbParameter> source = new List <DbParameter> {
                DbFactory.CreateDbParameter(DbHelper.DbParmChar + str, propertyValue)
            };

            return(DatabaseReader.ReaderToModel <T>(DbHelper.ExecuteReader(CommandType.Text, builder.ToString(), source.ToArray <DbParameter>())));
        }