亲爱的, 我试图调用一个查询,它可以只显示不同名称的数据,也可以根据其他条件显示数据:
Dear all, I am trying to call a query, which can display data by distinct names only and based on other conditions as well:
DateTime? yesterday = DateTime.Today.AddBusinessDays(-4); var data = from c in db.data_qy where c.UploadDate == yesterday && c.Cover == "storm" .OrderByDescending(a => a.UploadDate) .Distinct() select (c.Name); if (!data.Any()) { var message = string.Format("No data found"); return Request.CreateErrorResponse(HttpStatusCode.NotFound, message); } return Request.CreateResponse(HttpStatusCode.OK, new {data }); }我目前正在收到 - 'char'不包含'UploadDate'的定义且没有扩展名可以找到方法'UploadDate'接受'char'类型的第一个参数(你是否缺少using指令或汇编引用?) - 'UploadDate'where子句中的错误。 请提供建议,我可能会在上面的代码中遗漏。 提前谢谢。
I am currently getting a -- 'char' does not contain a definition for 'UploadDate' and no extension method 'UploadDate' accepting a first argument of type 'char' could be found (are you missing a using directive or an assembly reference?) -- error on the 'UploadDate' where clause. Please advice, in what I may be missing from the code above. Thanks in advance.
推荐答案试试这个... try this... var data = (from c in db.data_qy where c.UploadDate == yesterday && c.Cover == "storm" select (c.Name)).OrderByDescending(a => a.UploadDate).Distinct();
嘿,你必须来自巴基斯坦???右:D hey u must be from pakistan ??? right :D
更多推荐
linq问题中不同的一栏
发布评论