How do you write a get method that retrieves the title of an object, not its Id - w/ ASP.NET MVC -
so method in repository use records db via id
    public blogstable getblogposts(int id)     {         return db.blogstables.singleordefault(d => d.id == id);     }   and controller using method
    public actionresult details(int id)     {         blogstable blogpostdetails = repo.getblogposts(id);          return view(blogpostdetails);     }   what need able write method allows me records db title, instead of id. have now
also, how set route use method? have now
            routes.maproute(             "default",                                                           "{controller}/{action}/{id}",                                        new { controller = "blog", action = "index", id = "" }           );      
    public blogstable getblogpostsbytitle(string title)     {         return db.blogstables.singleordefault(d => d.title == title);     }      public actionresult details(string id)     {         blogstable blogpostdetails = repo.getblogpostsbytitle(id);          return view(blogpostdetails);     }      
Comments
Post a Comment