Пример #1
0
 /// <summary>
 /// 从数据库中删除指定的实体,是以主键方式删除
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>删除成功则返回true</returns>
 public bool Delete(Post entity)
 {
    return PostDAL.Instance.Delete(entity);
 }
Пример #2
0
 /// <summary>
 /// 更新数据行
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>更新成功则返回true</returns>
 public bool Update(Post entity)
 {
    return PostDAL.Instance.Update(entity);
 }
Пример #3
0
 public static MvcHtmlString PostLink(this HtmlHelper helper, Post post)
 {
   return helper.ActionLink(post.Title, "Index", "Blog", new { year = post.PostedOn.Year, month = post.PostedOn.Month, title = post.UrlSlug }, new { title = post.Title });
 }
Пример #4
0
 public bool Add(Post entity)
 {
     return PostDAL.Instance.Add(entity);
 }
Пример #5
0
 /// <summary>
 /// 对于多对多的关联,需要进行二次查询获取对应的数据
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public List<Tag> GetTags(Post p)
 {
     var subQuery = new SqlLam<PostTagMap>().Where(x=>x.Post_id==p.Id).SelectDistinct(x=>x.Tag_id);
     var query = new SqlLam<Tag>().WhereIsIn(x => x.TagId, subQuery);
     return CONN.SQLQuery<Tag>(query.QueryString, query.QueryParameters).ToList();
 }
Пример #6
0
 /// <summary>
 /// 单词查询获取对应的类目
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public Category GetCategory(Post p)
 {
     
     return CONN.Where<Category>(x=>x.CategoryId==p.Category).First();
 }
Пример #7
0
 /// <summary>
 /// Update an existing post.
 /// </summary>
 /// <param name="post"></param>
 public void EditPost(Post post)
 {
     CONN.Update(post);
 }
Пример #8
0
 /// <summary>
 /// Adds a new post and returns the id.
 /// </summary>
 /// <param name="post"></param>
 /// <returns>Newly added post id</returns>
 public int AddPost(Post post)
 {
     CONN.Insert(post);
     return post.Id;
 }
Пример #9
0
 /// <summary>
 /// 更新数据行
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>更新成功则返回true</returns>
 public bool Update(Post entity)
 {
    return CONN.Update<Post>(entity);            
 }
Пример #10
0
 /// <summary>
 /// 从数据库中删除指定的实体,是以主键方式删除
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>删除成功则返回true</returns>
 public bool Delete(Post entity)
 {         
    return CONN.Delete<Post>(entity);
 }
Пример #11
0
 /// <summary>
 /// 在数据库中添加行,如果主键是自增的那么设置主键是没有意义的
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public bool Add(Post entity)
 {
     return CONN.Insert<Post>(entity);            
 }