我有这个模型
public class DocumentModel
{
public int documentID { get; set; }
public String Title { get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime DateCreated { get; set; }
public String Description { get; set; }
public int authorID { get; set; }
public String AuthorName { get; set; }
public int categoryID { get; set; }
public String Category { get; set; }
public int topicID { get; set; }
public String Topic { get; set; }
[AllowHtml]
public String DocumentBody { get; set; }
}
当我在mysql中进行查询后要填充我的模型时,这是代码
result = from DataRow row in data.Rows
select new DocumentModel()
{
documentID = (int)row["document_id"],
Title = row["title"].ToString(),
DateCreated = (DateTime)row["date_created"],
Description = row["description"].ToString(),
AuthorName = row["AuthorName"].ToString(),
categoryID = (int)row["category"],
topicID = (int)row["topicID"]
};
我在 CategoryID 和 TopicID 中有错误,错误显示“指定的演员表无效”。我不知道我从哪里得到那个错误我已经检查了所有的数据类型是否正确并且我确认它都是正确的你能给我建议吗?我错过了一些错误实现的代码吗?
在我忘记之前是我的 MYsql 查询代码
select a.document_id,a.title,date(a.date_created) as date_created,a.Description,c.first_name as AuthorName,ifnull(e.category_ID, 0) as category, ifnull(d.ID,0) as TopicID from tbldocument a
Inner join tbldocumenttree b on a.document_ID = b.Document_ID
left join tblcategory e on b.category_id = e.category_id
Inner join tblauthor c on a.author_id = c.author_id
left join tbldocumenttree d on d.ID = b.parent
谢谢你。