Ejemplo n.º 1
0
        public void Update(RoleUserRelation item)
        {
            if(item.ChangedPropertyCount>0)
                {
                    StringBuilder sqlbuilder = new StringBuilder();
                    sqlbuilder.Append("UPDATE [RoleUserRelation] SET ");
                    Dictionary<string,string> cols =new Dictionary<string,string>();
                    cols.Add("LastUpdateUserUID","[LastUpdateUserUID]");
                    cols.Add("LastUpdateUserName","[LastUpdateUserName]");
                    cols.Add("LastUpdateTime","[LastUpdateTime]");
                    int i = 0;
                    //UPDATE COLUMNS
                    foreach (string p in item.ChangedPropertyList)
                    {
                        if(!cols.ContainsKey(p))
                        {
                            continue;
                        }
                        if (i > 0)
                        {
                            sqlbuilder.Append(",");
                        }
                        sqlbuilder.AppendFormat("{0}=@{1}", cols[p], p);
                        i++;
                    }
                    //WHERE;
                    sqlbuilder.Append(" WHERE [RoleID]=@RoleID");

                    List<SqlParameter> SPParams = new List<SqlParameter>();
                     SPParams.Add(new SqlParameter("@RoleID",item.RoleID));
             SPParams.Add(new SqlParameter("@UserUID",item.UserUID));

                    if(item.IsChanged("LastUpdateUserUID"))
                    {
                        SPParams.Add(new SqlParameter("@LastUpdateUserUID",item.LastUpdateUserUID));
                    }
                    if(item.IsChanged("LastUpdateUserName"))
                    {
                        SPParams.Add(new SqlParameter("@LastUpdateUserName",item.LastUpdateUserName));
                    }
                    if(item.IsChanged("LastUpdateTime"))
                    {
                        SPParams.Add(new SqlParameter("@LastUpdateTime",item.LastUpdateTime));
                    }
                    base.ExecuteNonQuery(sqlbuilder.ToString(), SPParams.ToArray());
                }
        }
Ejemplo n.º 2
0
 public void Save(RoleUserRelation item)
 {
     if(item.IsNew)
         {
             Insert(item);
         }
         else
         {
             Update(item);
         }
 }
Ejemplo n.º 3
0
 public void Insert(RoleUserRelation item)
 {
     string sql="INSERT INTO [RoleUserRelation] ([RoleID],[UserUID],[LastUpdateUserUID],[LastUpdateUserName],[LastUpdateTime]) VALUES (@RoleID,@UserUID,@LastUpdateUserUID,@LastUpdateUserName,@LastUpdateTime)";
         List<SqlParameter> SPParams = new List<SqlParameter>();
         SPParams.Add(new SqlParameter("@RoleID",item.RoleID));
         SPParams.Add(new SqlParameter("@UserUID",item.UserUID));
         SPParams.Add(new SqlParameter("@LastUpdateUserUID",item.LastUpdateUserUID));
         SPParams.Add(new SqlParameter("@LastUpdateUserName",item.LastUpdateUserName));
         SPParams.Add(new SqlParameter("@LastUpdateTime",item.LastUpdateTime));
         base.ExecuteNonQuery(sql, SPParams.ToArray());
 }
Ejemplo n.º 4
0
 public List<RoleUserRelation> QueryAll()
 {
     string sql ="SELECT [RoleID],[UserUID],[LastUpdateUserUID],[LastUpdateUserName],[LastUpdateTime] FROM [RoleUserRelation]";
         List<RoleUserRelation>  list =new List<RoleUserRelation>();
         using(IDataReader reader = base.ExcuteDataReader(sql))
         {
             while(reader.Read())
             {
                 RoleUserRelation item =new RoleUserRelation();
                 item.RoleID = reader.GetInt32(0);
                     item.UserUID = reader.GetString(1);
                     item.LastUpdateUserUID = reader.GetString(2);
                     item.LastUpdateUserName = reader.GetString(3);
                     item.LastUpdateTime = reader.GetDateTime(4);
                                             list.Add(item);
             }
         }
         return list;
 }
Ejemplo n.º 5
0
        public RoleUserRelation Get(int key)
        {
            string sql = "SELECT [RoleID],[UserUID],[LastUpdateUserUID],[LastUpdateUserName],[LastUpdateTime] FROM [RoleUserRelation] WHERE [RoleID]=@RoleID";
                SqlParameter p =new SqlParameter("@RoleID",key);
                RoleUserRelation item =null;
                using(IDataReader reader = base.ExcuteDataReader(sql,p))
                {
                    if(reader.Read())
                    {
                        item =new RoleUserRelation();
                        item.RoleID = reader.GetInt32(0);
                            item.UserUID = reader.GetString(1);
                            item.LastUpdateUserUID = reader.GetString(2);
                            item.LastUpdateUserName = reader.GetString(3);
                            item.LastUpdateTime = reader.GetDateTime(4);

                    }
                }
                return item;
        }