Querying blobbed data

Is it possible to query blobbed data?

In your player example: https://gistlyn.com/?collection=991db51e44674ad01d3d318b24cf0934&gist=840bc7f09292ad5753d07cef6063893e

The phone numbers are blobbed. Is there anything I can do with that blobbed data in a query?

I tried this:

var test = db.From<Player>().Where(x => x.PhoneNumbers.Any(p => p.Kind == PhoneKind.Mobile));

var lookup = db.Select(test);

To see if it returned data but it gave me this error:

System.InvalidOperationException: 'variable 'x' of type 'OrmLiteTest.Player' referenced from scope '', but it is not defined'

I also tried this but with same error:

var test = db.From<Player>().Where(x => x.PhoneNumbers.Contains(new Phone { Kind = PhoneKind.Mobile }));

I looked through documentation but couldn’t see any examples of querying blobbed data. Is it possible? What can be done with it apart from serializing a list of a specific record?

No, the Query Expression needs to be converted to SQL that’s run on the RDBMS which isn’t possible with blobbed fields. You can only query the returned results where you can will be able to use LINQ on the generic collections.

Hi Mythz, Thanks for the quick reply.

I haven’t worked with blobbed data before but I assume I could search for a string inside the data as that is possible in SQL. Would I have to write the SQL for that of can I do with a LINQ expression?

I am using SQL 2017 which according to this page can query json data: https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-2017

Is there any abstraction for that in ORMLite or do I need to write the SQL query for this?

No OrmLite’s Typed API doesn’t query blobbed fields or execute any RDBMS-specific functionality.

You can use SqlList to execute any RDBMS-specific SQL otherwise if you need to query something make it a first-class property/column.

1 Like