示例#1
0
        /// <summary>
        /// Creates a stored procedure parameter for each property in the guest
        /// </summary>
        /// <param name="inviteId">Unique identifier of the invite the guest is a member of</param>
        /// <param name="includeId">Value determining whether or not the unique identifier of the guest should be included</param>
        /// <returns>Stored procedure parameter for each property in the guest</returns>
        internal sp.ParameterCollection GetParametersForStoredProcedure(Int32 inviteId, Boolean includeId)
        {
            sp.ParameterCollection parameters = new sp.ParameterCollection();

            if (includeId)
            {
                parameters.AddWithValue("GuestId", DbType.Int32, Id);
            }

            parameters.AddWithValue("InviteId", DbType.Int32, inviteId);
            parameters.AddWithValue("Forename", DbType.String, Forename);
            parameters.AddWithValue("Surname", DbType.String, Surname);
            parameters.AddWithValue("IsAttending", DbType.Boolean, IsAttending);
            parameters.AddWithValue("DateOfRsvp", DbType.DateTime, DateOfRsvp);
            parameters.AddWithValue("IsChild", DbType.Boolean, IsChild);
            parameters.AddWithValue("IsVegetarian", DbType.Boolean, IsVegetarian);
            parameters.AddWithValue("CanBringPlusOne", DbType.Boolean, CanBringPlusOne);
            parameters.AddWithValue("IsBringingPlusOne", DbType.Boolean, IsBringingPlusOne);
            parameters.AddWithValue("PlusOneForename", DbType.String, PlusOneForename);
            parameters.AddWithValue("PlusOneSurname", DbType.String, PlusOneSurname);
            parameters.AddWithValue("PlusOneIsVegetarian", DbType.Boolean, PlusOneIsVegetarian);
            parameters.AddWithValue("TableId", DbType.Int32, TableId);
            parameters.AddWithValue("RoomId", DbType.Int32, RoomId);
            parameters.AddWithValue("Notes", DbType.String, Notes);

            return(parameters);
        }
示例#2
0
        public override sp.ParameterCollection GetParametersForStoredProcedure(Boolean includeId)
        {
            sp.ParameterCollection parameters = new sp.ParameterCollection();

            if (includeId)
            {
                parameters.AddWithValue("FileTypeId", DbType.Int16, Id);
            }

            parameters.AddWithValue("Name", DbType.String, Name);
            parameters.AddWithValue("MediaItemType", DbType.Int16, Convert.ToInt16(MediaItemType));

            return(parameters);
        }
示例#3
0
        internal override sp.ParameterCollection GetParametersForStoredProcedure(Boolean includeId)
        {
            sp.ParameterCollection parameters = base.GetParametersForStoredProcedure(includeId);

            //get the ID of the parent
            object parentId = this.parent == null ? null : (object)this.parent.Id;

            //use the meta data attribute to create a parameter for the parent ID
            DbHierarchicalObjectMetaDataAttribute metaData = GetType().GetCustomAttribute <DbHierarchicalObjectMetaDataAttribute>();

            parameters.AddWithValue(metaData.ParentIdParameterName, metaData.IdParameterDataType, parentId);

            return(parameters);
        }
示例#4
0
        /// <summary>
        /// Converts each property in the object that is to be saved to the database to a parameter to pass to a command
        /// </summary>
        /// <param name="includeId">Value determining whether or not to include the object's unique identifier in the returned array</param>
        /// <returns>Array containing a command parameter for each property in the obect that is to be saved to the database</returns>
        internal virtual sp.ParameterCollection GetParametersForStoredProcedure(Boolean includeId)
        {
            sp.ParameterCollection    parameters = new sp.ParameterCollection();
            DbObjectMetaDataAttribute metaData   = GetType().GetCustomAttribute <DbObjectMetaDataAttribute>();

            if (includeId)
            {
                parameters.AddWithValue(metaData.IdParameterName, metaData.IdParameterDataType, Id);
            }

            foreach (PropertyInfo pi in GetType().GetProperties().Where(p => Attribute.IsDefined(p, typeof(sp.DataColumnAttribute))))
            {
                sp.DataColumnAttribute attribute = pi.GetCustomAttribute <sp.DataColumnAttribute>();
                parameters.AddWithValue(attribute.ColumnName, attribute.DataType, pi.GetValue(this));
            }

            return(parameters);
        }
示例#5
0
        public override sp.ParameterCollection GetParametersForStoredProcedure(bool includeId)
        {
            sp.ParameterCollection parameters = new sp.ParameterCollection();

            if (includeId)
            {
                parameters.AddWithValue("MediaItemId", DbType.Int64, Id);
            }

            parameters.AddWithValue("Type", DbType.Int16, Convert.ToInt16(Type));
            parameters.AddWithValue("Name", DbType.String, Name.Value);
            parameters.AddWithValue("Genre", DbType.String, Genre.Value);
            parameters.AddWithValue("IsHidden", DbType.Boolean, IsHidden);
            parameters.AddWithValue("DateCreated", DbType.DateTime, DateCreated);
            parameters.AddWithValue("DateModified", DbType.DateTime, DateModified);
            parameters.AddWithValue("UserName", DbType.String, UserName.Value);

            foreach (sp.Parameter parameter in GetMediaItemParametersForStoredProcedure())
            {
                parameters.Add(parameter);
            }

            return(parameters);
        }