我有以下代码。但它会导致异常。
using (var context = new blogEntities())
{
var listOfComments = context.Comments
.OrderByDescending(c => c.CreateDate)
.Where(c => c.CreateDate > fromDate)
.Select(c => new NewsFeedData()
{
ArticleID = c.ArticleID,
CommentID = c.CommentID,
Text = c.CommentText,
Author = c.Author,
CreateDate = c.CreateDate,
Type = 'C'
}).ToList();
}
比我尝试枚举但有一些问题。实现我想要的最佳方式是什么?我想为 Type 分配一些常量