在发布这个问题之前,我尝试根据我的问题进行搜索,但我找不到一个(可能不是搜索得那么好:(,我试图在 linq 查询中将我的字符串转换为整数,我得到了这个异常。
**
LINQ to Entities 无法识别方法 'Int32 ToInt32(System.String)' 方法,并且此方法无法转换为存储表达式
**
发布完整的查询可能会浪费你们的时间,所以我只是放弃了卡住的主线
int intBookingNumber = Convert.ToInt32(Booktime);
var query =
(from PROJECTS in db.PROJECTS
join WOes in db.WOes on PROJECTS.PRJ_ID equals WOes.PRJ_ID
join SEVTs in db.SEVTs on WOes.SEQNUM equals SEVTs.SEQNUM
join RSRCEs in db.RSRCEs on SEVTs.RESID equals RSRCEs.RESID
join PERS in db.PERS on RSRCEs.RECID equals PERS.RECID into PERS_join
from PERS in PERS_join.DefaultIfEmpty()
join RESTYPEs in db.RESTYPEs on new { RTYPE = SEVTs.RTYPE } equals new { RTYPE = RESTYPEs.CODE }
join RESCATs in db.RESCATs on new { RCAT = SEVTs.RCAT } equals new { RCAT = RESCATs.CODE }
join SEVT_EX in db.SEVT_EX on SEVTs.SESID equals SEVT_EX.SESID into SEVT_EX_join
from SEVT_EX in SEVT_EX_join.DefaultIfEmpty()
where
(new string[] { "1", "2" }).Contains((PROJECTS.STAT.TrimEnd()).TrimStart()) &&
(WOes.STAT.TrimEnd()).TrimStart() == "6" &&
((SEVTs.RESTYPE == 5 ||
SEVTs.RESTYPE == 0) &&
(RESTYPEs.USER2.Substring(2 - 1, 1) == "F" &&
RESTYPEs.USER2.Substring(6 - 1, 1) == "S") &&
SEVTs.TYPE == 0) ||
(SEVTs.RESTYPE == 4 &&
SEVTs.TYPE == 0) &&
RESCATs.GROUPID==0 &&
RESTYPEs.GROUPID==0 &&
(int?)(WOes.INVOICE.TrimStart()).Length > 0 &&
WOes.INVOICE.TrimStart() != "PENDING" &&
WOes.USERFLAG1 != 1 &&
//(SEVTs.T_START.TrimStart()) == (Booktime)
//Convert.ToInt32(SEVTs.T_START.TrimStart()) >= Convert.ToInt32(Booktime)
Convert.ToInt32(SEVTs.T_START) >= intBookingNumber
orderby
PROJECTS.PRJ_ID,
WOes.WONUM
select new
{
PROJECTS.PRJ_ID,
PROJECTS.USER3,
PROJECTS.USER9,
WOes.WONUM,
WOes.JOBDESC,
SEVTs.SESID,
SEVTs.RESTYPE,
SEVTs.TYPE,
SEVTs.T_START,
SEVTs.T_END,
SEVTs.MEALEND,
SEVTs.MELSTART3,
SEVTs.MELSTART2,
SEVTs.MELEND2,
Column1 = SEVTs.MELSTART2,
SEVTs.MELEND3,
SEVTs.USER2,
SEVTs.SUBACTID,
SEVTs.OT_EXEMPT,
USER5 = SEVT_EX.USER5,
SEVTs.GMT_OFFSET,
SEVTs.MEALSTART,
SEVTs.STANDARD,
RESCATs.USER1,
SEVTs.RESID
});
SEVTs.T_START.TrimStart()
两种bookingStart
数据类型都是字符串。显然他们在这里得到了数字。我如何在这里使用逻辑运算符。
非常感谢任何帮助。
找到周围的工作,这可以帮助我解决我的问题
**String.Compare(SEVTs.T_START.TrimStart(), Booktime) >= 0**