linq问题中不同的一栏

编程入门 行业动态 更新时间:2024-10-28 19:21:25
本文介绍了linq问题中不同的一栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的, 我试图调用一个查询,它可以只显示不同名称的数据,也可以根据其他条件显示数据:

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问题中不同的一栏

本文发布于:2023-10-14 19:00:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1491922.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:linq

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!