gpt4 book ai didi

c# - 无法在 lambda 表达式中转换此查询

转载 作者:太空宇宙 更新时间:2023-11-03 10:46:47 24 4
gpt4 key购买 nike

我一直坚持将此查询转换为 lambda 表达式。

SELECT        Timesheet_Detail_Id, Date, Proj_Id, Task_Id, Ticket_No, Description, Hours, IsBillable, Billing_Hrs, Link_To, Status_Id, Timesheet_Id, flag, Remarks, EntryDate
FROM dbo.Timesheet_details
WHERE (Link_To = 7) OR
(Link_To =
(SELECT User_Id FROM dbo.User_Details
WHERE(Leader_User_Id = 7)))

我的尝试:-

int linkto=Convert.ToInt32(Session["login_user_Id"]);
var list=de.User_Details.Where(y => y.Leader_User_Id==linkto).Select(y => y.User_Id);
lvTimesheet.DataSource = de.TimeSheetDetailViews.Where(x => x.Link_To == linkto || x.Link_To == list).ToList();

我想在 Lambda 表达式中转换此查询,但出现如下错误。

错误列表

Error   39  Cannot convert lambda expression to type 'string' because it is not a delegate type D:\Govinda\OfficeProjects\InfosenseTimeSheet\InfoSenseTimeSheet\InfoSenseTimeSheetWeb\ViewMyTimesheetList.aspx.cs   16  64  D:\...\InfoSenseTimeSheetWeb\

Error 40 Delegate 'System.Func<InfosenseTimeSheetModel.TimeSheetDetailView,int,bool>' does not take 1 arguments D:\Govinda\OfficeProjects\InfosenseTimeSheet\InfoSenseTimeSheet\InfoSenseTimeSheetWeb\ViewMyTimesheetList.aspx.cs 16 64 D:\...\InfoSenseTimeSheetWeb\

Error 41 Operator '==' cannot be applied to operands of type 'decimal' and 'System.Linq.IQueryable<decimal>' D:\Govinda\OfficeProjects\InfosenseTimeSheet\InfoSenseTimeSheet\InfoSenseTimeSheetWeb\ViewMyTimesheetList.aspx.cs 16 92 D:\...\InfoSenseTimeSheetWeb\

注意:-

SQL 查询工作正常。

最佳答案

我得到了答案

int linkto=Convert.ToInt32(Session["login_user_Id"]);
var list=de.User_Details.Where(y => y.Leader_User_Id==linkto).Select(y => y.User_Id);
lvTimesheet.DataSource = de.TimeSheetDetailViews.Where(x => x.Link_To == linkto || list.Contains(x.Link_To)).ToList();

关于c# - 无法在 lambda 表达式中转换此查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23081561/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com