Exemple #1
0
        public void DeleteBy(Action <TEntity> where)
        {
            TEntity local = (TEntity)Activator.CreateInstance(DynamicProxy.CreateDynamicProxyType <TEntity>());

            where (local);
            Dictionary <string, object> modifiedProperties = DynamicProxy.GetModifiedProperties(local);

            this.DeleteBy(modifiedProperties);
        }
Exemple #2
0
        public TEntity GetSingle(Action <TEntity> condition)
        {
            TEntity local = (TEntity)Activator.CreateInstance(DynamicProxy.CreateDynamicProxyType <TEntity>());

            condition(local);
            List <IDbDataParameter> dbParameters = new List <IDbDataParameter>();
            string strWhere = this.ParseConditionFromProxyEntity(local, dbParameters);

            return(GetList(string.Join(",", this._propertyNames), strWhere, null, dbParameters.ToArray()).FirstOrDefault());
        }
Exemple #3
0
        public IList <TEntity> GetList(Action <TEntity> where)
        {
            TEntity local = (TEntity)Activator.CreateInstance(DynamicProxy.CreateDynamicProxyType <TEntity>());

            where (local);
            List <IDbDataParameter> dbParameters = new List <IDbDataParameter>();
            string strWhere = this.ParseConditionFromProxyEntity(local, dbParameters);

            return(this.GetList(string.Join(",", this._propertyNames), strWhere, null, dbParameters.ToArray()));
        }
Exemple #4
0
        //public bool Exists(string where)
        //{
        //    string sql = "select count(1) from [" + this.TableName + "] where " + where;
        //    return this.Exists(sql);
        //}

        public bool Exists(Action <TEntity> where)
        {
            TEntity local = (TEntity)Activator.CreateInstance(DynamicProxy.CreateDynamicProxyType <TEntity>());

            where (local);
            List <IDbDataParameter> dbParameters = new List <IDbDataParameter>();
            string condition = this.ParseConditionFromProxyEntity(local, dbParameters);
            string sql       = "select " + string.Join(",", _properties.Select(x => x.Name)) + " from " + TableName;

            if (!string.IsNullOrWhiteSpace(condition))
            {
                sql += " where " + condition;
            }
            return(this.Exists(sql, dbParameters.ToArray()));
        }
Exemple #5
0
 public TEntity CreateProxy()
 {
     return((TEntity)Activator.CreateInstance(DynamicProxy.CreateDynamicProxyType <TEntity>()));
 }