I am using EF and I'm trying to query some records which have a version column like this:
var servicesWhichExistInDifferentDataCenters = dbContext.CurrentRunningServices
.Where(r => r.DeployedRing == ring
&& r.DataCenter == defaultDataCenterIndex
&& r.IsActive)
.AsEnumerable()
.Where(r => dbContext.CurrentRunningServices
.Any(r2 => r2.DeployedRing == r.DeployedRing
&& r2.DockerImageName == r.DockerImageName
&& r2.DataCenter != r.DataCenter
&& Version.Parse(r2.DeploymentVersion) != Version.Parse(r.DeploymentVersion)))
.AsEnumerable()
.ToList();
The LINQ expression 'DbSet() .Any(c => c.DeployedRing == __r_DeployedRing_0 && c.DockerImageName == __r_DockerImageName_1 && c.DataCenter != __r_DataCenter_2 && Version.Parse(c.DeploymentVersion) != __Parse_3)' could not be translated. Additional information: Translation of method 'System.Version.Parse' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
The query runs fine locally in VS, but I get the above error when running it on the server, even though the server is just running an image prepared from the local code. Why is it happening?