Posts

Showing posts with the label asp.net-mvc-3

Convert string to long type and use in a linq query within asp.net MVC

Convert string to long type and use in a linq query within asp.net MVC Is it possible within Linq in C#, to convert a string field in a database, to a long type - and use it in the query? Here, tme is a unix time (long) - but the field in the database, targetdate - is a string. I've tried: var qbt = db.Calls .Where(x => x.team == id && long.Parse(x.targetdate) <= tme); However I get the message: LINQ to Entities does not recognize the method 'Int64 Parse(System.String)' method, and this method cannot be translated into a store expression. LINQ to Entities does not recognize the method 'Int64 Parse(System.String)' method, and this method cannot be translated into a store expression. I know you can convert before the linq query, but is there any way of using it WITHIN the linq query? Thanks for any help, Mark "but the field in the database, targetdate - is a string" - there's your first problem.... ...