public Tags GetTags(int id) { using (var db = new Sova()) { return(db.Tags.FirstOrDefault(ta => ta.id == id)); } }
public int GetNumberOfComments() { using (var db = new Sova()) { return(db.Comments.Count()); } }
public int GetNumberOfPost_tag() { using (var db = new Sova()) { return(db.Post_tag.Count()); } }
public int GetNumberOfTags() { using (var db = new Sova()) { return(db.Tags.Count()); } }
public User GetUser(int id) { using (var db = new Sova()) { return(db.User.FirstOrDefault(c => c.id == id)); } }
public History GetHistory(int id) { using (var db = new Sova()) { return(db.HistoryList.FirstOrDefault(h => h.id == id)); } }
public int GetNumberOfUser() { using (var db = new Sova()) { return(db.User.Count()); } }
public Comment GetComment(int id) { using (var db = new Sova()) { return(db.Comments.FirstOrDefault(c => c.id == id)); } }
public int GetNumberOfLinkpost() { using (var db = new Sova()) { return(db.Linkpost.Count()); } }
public Linkpost GetLinkpost(int id) { using (var db = new Sova()) { return(db.Linkpost.FirstOrDefault(lp => lp.linkpostid == id)); } }
public SearchResult GetSearchResult(int id) { using (var db = new Sova()) { return(db.SearchResults.FirstOrDefault(s => s.id == id)); } }
public int GetCountOfHistoryList() { using (var db = new Sova()) { return(db.HistoryList.Count()); } }
public Post_tag GetPost_tag(int id) { using (var db = new Sova()) { return(db.Post_tag.FirstOrDefault(pt => pt.id == id)); } }
public Post GetPost(int id) { using (var db = new Sova()) { return(db.Posts.FirstOrDefault(p => p.id == id)); } }
public IList <SearchResult> EFShowSearchResult(string searchstring) { using (var db = new Sova()) { //var conn = (MySqlConnection)db.Database.GetDbConnection(); //conn.Open(); //var cmd = new MySqlCommand("call weightingsearch(@searchstring)", conn); //cmd.Parameters.Add("@searchstring", DbType.String).Value = searchstring; //var reader = cmd.ExecuteReader(); //var result = new List<SearchResult>(); //while(reader.HasRows && reader.Read()) //{ // result.Add(new SearchResult // { // id = reader.GetInt32(0), // Title = reader.GetString(2), // body = reader.GetString(3) // }); //} //return result; var result = db.Set <SearchResult>() .FromSql("call weightingsearch('" + searchstring + "')"); foreach (var data in result) { Console.WriteLine($"{data.id} {data.title} {data.body}"); } return(result.ToList()); } }
public void AddUser(User user) { using (var db = new Sova()) { user.id = db.User.Max(u => u.id) + 1; db.Add(user); db.SaveChanges(); } }
public void AddComment(Comment comment) { using (var db = new Sova()) { comment.id = db.Comments.Max(c => c.id) + 1; db.Add(comment); db.SaveChanges(); } }
public void AddPost(Post post) { using (var db = new Sova()) { post.id = db.Posts.Max(p => p.id) + 1; db.Add(post); db.SaveChanges(); } }
public void AddHistory(History history) { using (var db = new Sova()) { history.id = db.HistoryList.Max(h => h.id) + 1; db.Add(history); db.SaveChanges(); } }
public void AddTags(Tags tags) { using (var db = new Sova()) { tags.id = db.Tags.Max(ta => ta.id) + 1; db.Add(tags); db.SaveChanges(); } }
public void AddLinkpost(Linkpost linkpost) { using (var db = new Sova()) { linkpost.linkpostid = db.Linkpost.Max(lp => lp.linkpostid) + 1; db.Add(linkpost); db.SaveChanges(); } }
public void AddPost_tag(Post_tag pt) { using (var db = new Sova()) { pt.postid = db.Post_tag.Max(p => pt.id) + 1; db.Add(pt); db.SaveChanges(); } }
public IList <History> GetHistoryList(int page, int pagesize) { using (var db = new Sova()) { return(db.HistoryList .OrderBy(h => h.id) .Skip(page * pagesize) .ToList()); } }
//User public IList <User> GetUser(int page, int pagesize) { using (var db = new Sova()) { return(db.User .OrderBy(u => u.id) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
//Post public IList <Post> GetPosts(int page, int pagesize) { using (var db = new Sova()) { return(db.Posts .OrderBy(p => p.id) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
//Post_tag public IList <Post_tag> GetPost_tag(int page, int pagesize) { using (var db = new Sova()) { return(db.Post_tag .OrderBy(pt => pt.id) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
//Comments public IList <Comment> GetComments(int page, int pagesize) { using (var db = new Sova()) { return(db.Comments .OrderBy(c => c.id) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
//Linkpost public IList <Linkpost> GetLinkpost(int page, int pagesize) { using (var db = new Sova()) { return(db.Linkpost .OrderBy(lp => lp.linkpostid) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
//Tags public IList <Tags> GetTags(int page, int pagesize) { using (var db = new Sova()) { return(db.Tags .OrderBy(ta => ta.id) .Skip(page * pagesize) .Take(pagesize) .ToList()); } }
public void EFMarkThisPost(int postid, string searchstring) { using (var db = new Sova()) { var conn = (MySqlConnection)db.Database.GetDbConnection(); conn.Open(); var cmd = new MySqlCommand("call markthispost(@1,@2)", conn); cmd.Parameters.Add("@1", DbType.Int64).Value = postid; cmd.Parameters.Add("@2", DbType.String).Value = searchstring; Console.WriteLine($"Marked"); } }