I am using .NET Core 3.1, Microsoft.EntityFrameworkCore 3.1.9 and Npgsql 4.1.9. ProductRelease database entity has a version column - a string of numbers separated by a dot in major.minor.build.revision format. I would like to retrieve all the records where version <= 12.5.3.102197.
[Table("product_release", Schema = "test")]
public partial class ProductRelease
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("version")]
[StringLength(32)]
public string Version { get; set; }
}
I found a question where it is explained how to do it in raw SQL with string_to_array built-in function like this:
SELECT
*
FROM
test.product_release pr
WHERE
string_to_array(pr.version, '.')::int[] <= string_to_array('12.5.3.102197', '.')::int[];
How can I translate this query to EF Core (Npgsql). Is there a way to call string_to_array function from EF Core? I would like to avoid writing raw SQL queries.