在如果我把LINQ查询在MVC项目Model
,它是对MVC模式?
namespace DocLibrary.Models
{
public class Author
{
private DocLibraryContext db = new DocLibraryContext();
[Key]
public Int32 AuthorId { get; set; }
[StringLength(20)]
public String Name { get; set; }
..
public string GetNameById(int AuthorId)
{
var query = from a in db.Author
where a.AuthorId == AuthorId
select a.Name;
return query.FirstOrDefault();
}
public Author GetAuthorById(int AuthorId)
{
var query = from a in db.Author
where a.AuthorId.Equals(AuthorId)
select a;
return query.FirstOrDefault();
}
}
或者我应该将这些方法( GetNameById
, GetAuthorById
)来控制?