Possible to do a partial match with a Guid?
bzbetty opened this issue · comments
in SQL i can do a "Guid like '%blah%'" style query which I can't figure out how to do with this library.
Integers was a bit of work but the following worked
.Search(p => SqlFunctions.Convert((decimal)p.IntegerProperty))
I believe you could do something like...
var guid = Guid.NewGuid();
data.Search(p => p.StringPropertyContainingGuid).Containing(guid.ToString())
Could you expand on what you were trying to do with the integer
example?
You can currently work with integer properties (and other property types) in the following ways
data.Search(p => IntegerProperty).Between(1, 10);
data.Search(p => IntegerProperty).EqualTo(5);
data.Search(p => IntegerProperty).GreaterThan(1);
data.Search(p => IntegerProperty).LessThan(10);
data.Search(p => IntegerProperty).GreaterThanOrEqualTo(1);
data.Search(p => IntegerProperty).LessThanOrEqualTo(10);
Apologies if I am completely off track
sorry, completely opposite way around. I have a database field that contains a guid that I want to do a partial search on.
Ah, I see. So you want to return all records that contain a partial guid. Something like.
string partialGuid = "TE5T"
data.Search(p => p.GuidProperty).Containing(partialGuid);
Currently the .Containing
method is only valid for string comparisons but I can certainly look into adding functionality to support .Containing()
on non string properties
Yep that's exactly right.
Hi @bzbetty,
I haven't forgotten about this, quite the opposite. I've been trying all the tricks I can think of to get this to work but it seems that there is a limitation in linq to entities that means this simply isn't possible. 😢
I'm going to have a couple more goes at it, but the signs so far are that it's just not possible for linq to entities.
Sorry to say it, but I'm going to have to admit defeat. This just isn't possible with EF (6 at least).
It looks like EF7 has some additional expression capabilities that could make this possible but this is still currently in development and therefore not currently supported.
Apologies that this wasn't possible. I'll be keeping an eye on EF7 for the upcoming release
all good I suspected that might be the case. luckily for me I believe i can convert the column to a string.