/// <summary> /// 实体集合Reader /// </summary> /// <returns>实体集合</returns> protected static List<UsersFriendEntity> GetBindTDataList(SqlDataReader dataReader) { List< UsersFriendEntity> usersFriendList = new List< UsersFriendEntity>(); while (dataReader.Read()) { UsersFriendEntity usersFriendEntity = new UsersFriendEntity(); if (dataReader["Id"] != DBNull.Value) { usersFriendEntity.Id = new Guid(dataReader["Id"].ToString()); } if (dataReader["UserId"] != DBNull.Value) { usersFriendEntity.UserId = new Guid(dataReader["UserId"].ToString()); } if (dataReader["FriendId"] != DBNull.Value) { usersFriendEntity.FriendId = new Guid(dataReader["FriendId"].ToString()); } if (dataReader["AddTime"] != DBNull.Value) { usersFriendEntity.AddTime = Convert.ToDateTime(dataReader["AddTime"]); } if (dataReader["IsDel"] != DBNull.Value) { usersFriendEntity.IsDel = Convert.ToBoolean(dataReader["IsDel"]); } usersFriendList.Add(usersFriendEntity); } dataReader.Close(); dataReader.Dispose(); return usersFriendList; }
/// <summary> /// 更新 /// </summary> /// <param name="usersFriendEntity">实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public static bool Update( UsersFriendEntity usersFriendEntity , SqlTransaction tran) { List<SqlParameter> parameters = new List<SqlParameter>(); parameters.Add(SqlServerHelper.CreateInputParameter("@Id", SqlDbType.UniqueIdentifier, usersFriendEntity.Id)); parameters.Add(SqlServerHelper.CreateInputParameter("@UserId", SqlDbType.UniqueIdentifier, usersFriendEntity.UserId)); parameters.Add(SqlServerHelper.CreateInputParameter("@FriendId", SqlDbType.UniqueIdentifier, usersFriendEntity.FriendId)); parameters.Add(SqlServerHelper.CreateInputParameter("@AddTime", SqlDbType.DateTime, usersFriendEntity.AddTime)); parameters.Add(SqlServerHelper.CreateInputParameter("@IsDel", SqlDbType.Bit, usersFriendEntity.IsDel)); if (tran == null) { SqlServerHelper.ExecuteNonQuery(CommandType.Text, SqlUpdate, parameters.ToArray()); return true; } SqlServerHelper.ExecuteNonQuery(tran, CommandType.Text, SqlUpdate, parameters.ToArray()); return true; }
/// <summary> /// 创建 /// </summary> /// <param name="usersFriendEntity">实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public static Guid InsertReturnID( UsersFriendEntity usersFriendEntity , SqlTransaction tran) { List<SqlParameter> parameters = new List<SqlParameter>(); parameters.Add(SqlServerHelper.CreateInputParameter("@UserId", SqlDbType.UniqueIdentifier, usersFriendEntity.UserId)); parameters.Add(SqlServerHelper.CreateInputParameter("@FriendId", SqlDbType.UniqueIdentifier, usersFriendEntity.FriendId)); parameters.Add(SqlServerHelper.CreateInputParameter("@AddTime", SqlDbType.DateTime, usersFriendEntity.AddTime)); parameters.Add(SqlServerHelper.CreateInputParameter("@IsDel", SqlDbType.Bit, usersFriendEntity.IsDel)); Guid result = Guid.Empty; if (tran == null) { Guid.TryParse(SqlServerHelper.ExecuteScalar(CommandType.Text, SqlInsertReturnID, parameters.ToArray()).ToString(), out result); } else { Guid.TryParse(SqlServerHelper.ExecuteScalar(tran, CommandType.Text, SqlInsertReturnID, parameters.ToArray()).ToString(), out result); } return result; }
/// <summary> /// 更新 /// </summary> /// <param name=" usersFriendEntity">实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public bool Update( UsersFriendEntity usersFriendEntity , SqlTransaction tran) { return UsersFriendDAL.Update(usersFriendEntity, tran); }
/// <summary> /// 创建 /// </summary> /// <param name=" usersFriendEntity">实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public Guid InsertReturnID( UsersFriendEntity usersFriendEntity , SqlTransaction tran) { return UsersFriendDAL.InsertReturnID(usersFriendEntity, tran); }
/// <summary> /// 创建 /// </summary> /// <param name=" usersFriendEntity">实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public bool Insert( UsersFriendEntity usersFriendEntity , SqlTransaction tran) { return UsersFriendDAL.Insert(usersFriendEntity, tran); }