Solved

Comparing a hex to a string in Linq to Entities query expression

Posted on 2014-03-05
1
309 Views
Last Modified: 2016-02-10
mch.Machine_ID  is the hex value and mId is the string value.

How do I compare a Hex value to a string in LINQ to Entities Query string below?

var loc1 = (from mch in CRMEDM.edm1.m_Location
                         where mch.Machine_ID.ToString() == mId
                         select mch).ToList();

My error message: LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
0
Comment
Question by:metro156
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39906672
What do you mean by "hex value"? A hexadecimal value is just a number, represented in a different base. If you're storing it as a number, then you should be comparing two numbers; otherwise, if you have this encoded as a hexadecimal string, then you should be able to do simple string comparison.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question