Before post this question i try search based on my problem i couldn't find one (may be am not search that well :(, i was trying to convert my string to integer in the linq query i got this exception.
**
LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression
**
Posting full query might be time wasting for you guys so i just dropped the main line where i get stuck
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()
and bookingStart
both data types are string. Obviously they are getting numbers here . how can i use the logic operator here.
Any help much appreciated.
Find the work around guys, this help me to solve my problem
**String.Compare(SEVTs.T_START.TrimStart(), Booktime) >= 0**