As an example take a simple poco with an ID and a string property called data.
What would be the best way to call COMPRESS(data) before saving the entity using EF Core and calling DECOMPRESS(data) on loading it. The database column of course would be VARBINARY.
Detailed:
Writing custom SQL to achieve this (based on the above example) would look like this:
SELECT Id, DECOMPRESS(@Data) as [Data]
FROM table
for selecting and like this for inserting an entity:
INSERT INTO table
VALUES(@Id, COMPRESS(@Data))
Notes:
It's SQL Server.
The current string length can go up to a few thousand, as such a fixed-length NVARCHAR using PAGE or ROW compression on the DB side are not an option.