score:1

Accepted answer

Use ExecuteStoreQuery on your context and execute a custom SQL statement directly against your context. Something like:

string prefix = '00000000';       
const string sql = "select * from myEntities where id like @prefix + '%'"; 
var matches = context.ExecuteStoreQuery<MyEntityType>(sql, prefix);

Also, check out this MSDN example.

score:4

Two options: 1) change your entity data model so that whatever "x" signifies, it is moved to a property on that entity instead of tightly coupled to the unique id

2) get the whole list of entities into a collection, then after they are loaded into memory, go through and do a id.ToString().Contains() query on the collection. Once it has been loaded into memory the CLR will allow this. Though, horrible overhead.

I'd go with #1 if possible.


Related Query

More Query from same tag