Solved

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

Posted on 2014-03-05
1
303 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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