74403

Which method of canonical EntityFunctions for .ToString()

Question:

I am using EF and if I use expression like:

JobLinkId = jobItem.joblinkid.ToString()

it throws error because it is C# function. Which method of EF canonical functions should I use for this?

Answer1:

I'm guessing that you're trying to use ToString in Linq to Entities query. If so then its impossible to use it there. The only walkaround i know is to use ToList on query and then use Linq to Objects to get result with ToString.

Answer2:

To something like this:

instead of JobItem.joblinkid.ToString() use only JobItem.joblinkid inside your query and do a select afterwards:

myQuery.ToArray().Select(x => x.joblinkid.ToString())

I hope you get it. In any case: int is <em>better</em> than string, just wait till you really need the string and convert then.

Recommend

  • Python: Mapping between two arrays with an index array
  • Implementation of Thread-local storage (TLS) in C/C++ (multithreading)
  • how to compile code from svn into jar file?
  • doing database write after the response
  • Name hiding in constructor initialization list
  • Linq to Sql Foreign key relationships
  • How can I organize this data into the objects I want with LINQ?
  • datatables left join c#
  • Finding All Combinations (cartesian product) of list values in vb.net
  • Cannot use a lambda expression as an argument to a dynamically dispatched operation
  • Finding parents in a tree hierarchy for a given child LINQ (lambda expression)
  • Jhipster: How to create relationships with User entity using supplied tools?
  • ASP.NET, C# How to Pass a StringQuery to a custom SQL Command
  • JPA/EclipseLink Returning No Results
  • How to Divide an array on c#?
  • string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class
  • Many to Many in Linq using Dapper
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • Multiple Left Join LINQ-to-entities
  • Double dispatch in Java example
  • Exception creating JSON with LINQ
  • Linq Merge lists
  • Force show.bind execution
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Trying to switch camera back to front but getting exception
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Display Images one by one with next and previous functionality
  • Why winpcap requires both .lib and .dll to run?
  • SQL merge duplicate rows and join values that are different
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • need help with bizarre java.net.HttpURLConnection behavior
  • Programmatically clearing map cache
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?