public virtual SkinPreview UpdateSkinPreview(SkinPreview entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            SkinPreview other = GetSkinPreview(entity.SkinPreviewId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update SkinPreview set  [SkinPreviewGUID]=@SkinPreviewGUID
							, [SkinID]=@SkinID
							, [Name]=@Name
							, [GroupName]=@GroupName
							, [CreatedOn]=@CreatedOn 
							 where SkinPreviewID=@SkinPreviewID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@SkinPreviewID", entity.SkinPreviewId)
                , new SqlParameter("@SkinPreviewGUID", entity.SkinPreviewGuid)
                , new SqlParameter("@SkinID", entity.SkinId)
                , new SqlParameter("@Name", entity.Name)
                , new SqlParameter("@GroupName", entity.GroupName ?? (object)DBNull.Value)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetSkinPreview(entity.SkinPreviewId));
        }
        public virtual SkinPreview InsertSkinPreview(SkinPreview entity)
        {
            SkinPreview other = new SkinPreview();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into SkinPreview ( [SkinPreviewGUID]
				,[SkinID]
				,[Name]
				,[GroupName]
				,[CreatedOn] )
				Values
				( @SkinPreviewGUID
				, @SkinID
				, @Name
				, @GroupName
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@SkinPreviewID", entity.SkinPreviewId)
                    , new SqlParameter("@SkinPreviewGUID", entity.SkinPreviewGuid)
                    , new SqlParameter("@SkinID", entity.SkinId)
                    , new SqlParameter("@Name", entity.Name)
                    , new SqlParameter("@GroupName", entity.GroupName ?? (object)DBNull.Value)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetSkinPreview(Convert.ToInt32(identity)));
            }
            return(entity);
        }