Ejemplo n.º 1
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanRole"/>, with keys in the <c>aFanRole</c> argument.
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and    t1.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
         vStringBuilder.AppendLine("and    t0.ROL_key = @ROLkey");
         vSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected FanRole not found: FAN_Key = {0}, ROL_key = {1}", aFanRole.FanKey, aFanRole.Rolkey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanRole, vSqlDataReader);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///   The <c>AddFanRole</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="FanRole"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="FanRoleBusiness"/> with the newly deserialized <see cref="FanRole"/> object.
 ///   Finally, it returns the inserted object (now with an assigned FanRole Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="FanRole"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string AddFanRole(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddFanRole");
     }
     FanRole vFanRole = new FanRole();
     vFanRole = XmlUtils.Deserialize<FanRole>(aXmlArgument);
     FanRoleBusiness.Insert(aFanKey, vFanRole);
     return XmlUtils.Serialize<FanRole>(vFanRole, true);
 }
Ejemplo n.º 3
0
        /// <summary>
        ///   The <c>DeleteFanRole</c> implementation method deserializes an incoming XML Argument as a new <see cref="FanRole"/> object.
        ///   It invokes the <c>Delete</c> method of <see cref="FanRoleBusiness"/> with the newly deserialized <see cref="FanRole"/> object.
        ///   Finally, it returns the Deleted object unchanged as a serialized <c>string</c> of XML.
        /// </summary>
        /// <param name="aXmlArgument">A XML Argument <see cref="string"/>.</param>
        /// <returns><see cref="FanRole"/> as XML <see cref="string"/>.</returns>
        /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
        public static string DeleteFanRole(FanKey aFanKey, string aXmlArgument)
        {
            if (aXmlArgument == null)
            {
                throw new ArgumentNullException("aXmlArgument of DeleteFanRole");
            }
            FanRole vFanRole = new FanRole();

            vFanRole = XmlUtils.Deserialize <FanRole>(aXmlArgument);
            FanRoleBusiness.Delete(aFanKey, vFanRole);
            return(XmlUtils.Serialize <FanRole>(vFanRole, true));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Delete a <see cref="FanRole"/> object passed as an argument.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanRole">A <see cref="FanRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
        public static void Delete(FanKey aFanKey, FanRole aFanRole)
        {
            if (aFanRole == null)
            {
                throw new ArgumentNullException("Delete FanRole Business");
            }

            if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanRole", AccessMode.Delete))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Delete, "FanRole");
            }

            FanRoleData.Delete(aFanRole);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Insert a <see cref="FanRole"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>FanRole Key</i>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aFanRole">A <see cref="FanRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
        public static void Insert(UserKey aUserKey, FanRole aFanRole)
        {
            if (aFanRole == null)
            {
                throw new ArgumentNullException("Insert FanRole Business");
            }

            if (!UserFunctionAccessData.HasModeAccess(aUserKey, "FanRole", AccessMode.Create))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.Create, "FanRole");
            }

            FanRoleData.Insert(aFanRole);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///   Update a <see cref="FanRole"/> object passed as an argument.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanRole">A <see cref="FanRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
        public static void Update(FanKey aFanKey, FanRole aFanRole)
        {
            if (aFanRole == null)
            {
                throw new ArgumentNullException("Update FanRole Business");
            }

            if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanRole", AccessMode.Update))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Update, "FanRole");
            }

            FanRoleData.Update(aFanRole);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///   Delete a <see cref="FanRole"/> object passed as an argument.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aFanRole">A <see cref="FanRole"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
        public static void Delete(UserKey aUserKey, FanRole aFanRole)
        {
            if (aFanRole == null)
            {
                throw new ArgumentNullException("Delete FanRole Business");
            }

            if (!UserFunctionAccessData.HasModeAccess(aUserKey, "FanRole", AccessMode.Delete))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.Delete, "FanRole");
            }

            FanRoleData.Delete(aFanRole);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanRoleCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanRoleCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanRoleCollection");
            }

            _isFiltered = (aSource as FanRoleCollection)._isFiltered;
            _fanKeyFilter = (aSource as FanRoleCollection)._fanKeyFilter;
            _fanRoleList.Clear();
            foreach (FanRole vFanRoleSource in (aSource as FanRoleCollection)._fanRoleList)
            {
                FanRole vFanRoleTarget = new FanRole();
                vFanRoleTarget.AssignFromSource(vFanRoleSource);
                _fanRoleList.Add(vFanRoleTarget);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanRoleCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanRoleCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanRoleCollection");
            }

            _isFiltered   = (aSource as FanRoleCollection)._isFiltered;
            _fanKeyFilter = (aSource as FanRoleCollection)._fanKeyFilter;
            _fanRoleList.Clear();
            foreach (FanRole vFanRoleSource in (aSource as FanRoleCollection)._fanRoleList)
            {
                FanRole vFanRoleTarget = new FanRole();
                vFanRoleTarget.AssignFromSource(vFanRoleSource);
                _fanRoleList.Add(vFanRoleTarget);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanRoleList</c> property a <see cref="FanRoleCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanRole"/>, filtered by the filter properties of the passed <see cref="FanRoleCollection"/>.
 /// </summary>
 /// <param name="aFanRoleCollection">The <see cref="FanRoleCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanRoleCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanRoleCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanRoleCollection aFanRoleCollection)
 {
     if (aFanRoleCollection == null)
     {
         throw new ArgumentNullException("aFanRoleCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanRoleCollection.IsFiltered)
         {
             if (aFanRoleCollection.FanKeyFilter > 0)
             {
                 vStringBuilder.AppendLine("and    t1.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRoleCollection.FanKeyFilter);
             }
         }
         vStringBuilder.AppendLine("order by t2.FRL_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanRole = new FanRole();
                 DataToObject(vFanRole, vSqlDataReader);
                 aFanRoleCollection.FanRoleList.Add(vFanRole);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 ///   Delete a <see cref="FanRole"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanRole">The <see cref="FanRole"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 public static void Delete(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FRL_FanRole");
         vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
         vStringBuilder.AppendLine("and    ROL_key = @ROLkey");
         vSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        ///   Update a <see cref="FanRole"/> passed as an argument .
        /// </summary>
        /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
        public static void Update(FanRole aFanRole)
        {
//            if (aFanRole == null)
//            {
//                throw new ArgumentNullException("aFanRole");
//            }
//            using (var vSqlCommand = new SqlCommand()
//            {
//                CommandType = CommandType.Text,
//                Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
//            })
//            {
//                var vStringBuilder = new StringBuilder();
//                vStringBuilder.AppendLine("update FRL_FanRole");
//");
//                vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
//                vStringBuilder.AppendLine("and    ROL_key = @ROLkey");
//                ObjectToData(vSqlCommand, aFanRole);
//                vSqlCommand.CommandText = vStringBuilder.ToString();
//                vSqlCommand.Connection.Open();
//                vSqlCommand.ExecuteNonQuery();
//                vSqlCommand.Connection.Close();
//            }
        }
Ejemplo n.º 13
0
 /// <summary>
 ///   Insert a <see cref="FanRole"/> passed as an argument via Stored Procedure that returns the newly inserted FanRole Key
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 public static void Insert(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into FRL_FanRole");
         vStringBuilder.AppendLine("       (FAN_Key, ROL_key)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@FANKey, @ROLkey)");
         ObjectToData(vSqlCommand, aFanRole);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 ///   Insert a <see cref="FanRole"/> passed as an argument via Stored Procedure that returns the newly inserted FanRole Key 
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 public static void Insert(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into FRL_FanRole");
         vStringBuilder.AppendLine("       (FAN_Key, ROL_key)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@FANKey, @ROLkey)");
         ObjectToData(vSqlCommand, aFanRole);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 ///   Delete a <see cref="FanRole"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanRole">The <see cref="FanRole"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 public static void Delete(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FRL_FanRole");
         vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
         vStringBuilder.AppendLine("and    ROL_key = @ROLkey");
         vSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanRole"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFanRole">A <see cref="FanRole"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanRole aFanRole)
 {
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
     aSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
 }
Ejemplo n.º 17
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanRole"/> object.
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanRole aFanRole, SqlDataReader aSqlDataReader)
 {
     aFanRole.FanKey         = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanRole.FanDisplayName = Convert.ToString(aSqlDataReader["FAN_DisplayName"]);
     aFanRole.Rolkey         = Convert.ToInt32(aSqlDataReader["ROL_key"]);
 }
Ejemplo n.º 18
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanRole"/>, with keys in the <c>aFanRole</c> argument.
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanRole</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanRole aFanRole)
 {
     if (aFanRole == null)
     {
         throw new ArgumentNullException("aFanRole");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and    t1.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
         vStringBuilder.AppendLine("and    t0.ROL_key = @ROLkey");
         vSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected FanRole not found: FAN_Key = {0}, ROL_key = {1}", aFanRole.FanKey, aFanRole.Rolkey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanRole, vSqlDataReader);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanRole"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFanRole">A <see cref="FanRole"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanRole aFanRole)
 {
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanRole.FanKey);
     aSqlCommand.Parameters.AddWithValue("@ROLkey", aFanRole.Rolkey);
 }
Ejemplo n.º 20
0
 /// <summary>
 ///   Update a <see cref="FanRole"/> passed as an argument .
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/>.</param>
 public static void Update(FanRole aFanRole)
 {
     //            if (aFanRole == null)
     //            {
     //                throw new ArgumentNullException("aFanRole");
     //            }
     //            using (var vSqlCommand = new SqlCommand()
     //            {
     //                CommandType = CommandType.Text,
     //                Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     //            })
     //            {
     //                var vStringBuilder = new StringBuilder();
     //                vStringBuilder.AppendLine("update FRL_FanRole");
     //");
     //                vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
     //                vStringBuilder.AppendLine("and    ROL_key = @ROLkey");
     //                ObjectToData(vSqlCommand, aFanRole);
     //                vSqlCommand.CommandText = vStringBuilder.ToString();
     //                vSqlCommand.Connection.Open();
     //                vSqlCommand.ExecuteNonQuery();
     //                vSqlCommand.Connection.Close();
     //            }
 }
Ejemplo n.º 21
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanRole"/> object.
 /// </summary>
 /// <param name="aFanRole">A <see cref="FanRole"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanRole aFanRole, SqlDataReader aSqlDataReader)
 {
     aFanRole.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanRole.FanDisplayName = Convert.ToString(aSqlDataReader["FAN_DisplayName"]);
     aFanRole.Rolkey = Convert.ToInt32(aSqlDataReader["ROL_key"]);
 }
Ejemplo n.º 22
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanRoleList</c> property a <see cref="FanRoleCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanRole"/>, filtered by the filter properties of the passed <see cref="FanRoleCollection"/>.
 /// </summary>
 /// <param name="aFanRoleCollection">The <see cref="FanRoleCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanRoleCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanRoleCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanRoleCollection aFanRoleCollection)
 {
     if (aFanRoleCollection == null)
     {
         throw new ArgumentNullException("aFanRoleCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanRoleCollection.IsFiltered)
         {
             if (aFanRoleCollection.FanKeyFilter > 0)
             {
                 vStringBuilder.AppendLine("and    t1.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanRoleCollection.FanKeyFilter);
             }
         }
         vStringBuilder.AppendLine("order by t2.FRL_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanRole = new FanRole();
                 DataToObject(vFanRole, vSqlDataReader);
                 aFanRoleCollection.FanRoleList.Add(vFanRole);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }