public virtual TopicStore UpdateTopicStore(TopicStore entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            TopicStore other = GetTopicStore(entity.TopicId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update TopicStore set  [ID]=@ID
							, [StoreID]=@StoreID
							, [CreatedOn]=@CreatedOn 
							 where TopicID=@TopicID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@TopicID", entity.TopicId)
                , new SqlParameter("@ID", entity.Id)
                , new SqlParameter("@StoreID", entity.StoreId)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetTopicStore(entity.TopicId));
        }
        public virtual TopicStore InsertTopicStore(TopicStore entity)
        {
            TopicStore other = new TopicStore();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into TopicStore ( [TopicID]
				,[ID]
				,[StoreID]
				,[CreatedOn] )
				Values
				( @TopicID
				, @ID
				, @StoreID
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@TopicID", entity.TopicId)
                    , new SqlParameter("@ID", entity.Id)
                    , new SqlParameter("@StoreID", entity.StoreId)
                    , 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(GetTopicStore(Convert.ToInt32(identity)));
            }
            return(entity);
        }