SQL查询与group by and and efference the接收参数
我正在尝试在linq ef中做到这一点我的SQL查询:
SELECT date FROM tab_4009_atv
WHERE id_asset IN ['ako','bj89','flity76']
GROUP BY date;
但是有一个特定的情况。 我要过滤的列表是作为这样的参数收到的:
public async Task<IEnumerable< Date>> getDates (IEnumerable< string>assetList){ }.
我该怎么做?谢谢!
I'm trying to do in Linq EF this my sql query:
SELECT date FROM tab_4009_atv
WHERE id_asset IN ['ako','bj89','flity76']
GROUP BY date;
but there's a specific situation.
This list that I'm filtering is received as a parameter like this:
public async Task<IEnumerable< Date>> getDates (IEnumerable< string>assetList){ }.
How can I do this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您给出的SQL查询和C#方法签名并不真正适合彼此。 SQL查询返回一个日期分组,但是C#方法返回日期列表。我们需要修改该方法的返回类型。
另一方面,与SQL或LINQ相比,这个问题更多是要将字符串转换为
Asset
对象。由于我们不知道Asset
对象看起来像我们无法帮助您进行转换。我们必须将这一责任委托给另一种方法。此外,该方法不需要异步。
以下代码应执行您要寻找的内容。
The SQL query and the C# method signature you have given don't really fit each other. SQL query returns a grouping of dates, but the C# method returns a list of dates. We need to modify the return type of the method.
On the other hand, this question is more about converting the string to the
Asset
object than SQL or LINQ. Since we do not know what theAsset
object looks like we cannot help you with that conversion. We have to delegate that responsibility to another method.Additionally, the method doesn't need to be async.
The following code should do what you are looking for.