I have the following helper method:
public static double CalculateKilosPerMeter(double diameter, double thickness)
{
return (diameter - thickness) * thickness * Math.PI * 0.008;
}
I use it when creating an instance of a Model class for a specific entity.
return pt => new ViewablePipeTypeModel()
{
Id = pt.Id,
KilosPerMeter = Logic.CalculateKilosPerMeter(pt.Diameter, pt.Thickness)
};
When I execute the code above, I get the following exception:
LINQ to Entities does not recognize the method 'Double CalculateKilosPerMeter(Double, Double)' method, and this method cannot be translated into a store expression
So, I suppose this is because EF requires an ExpressionFunc.
How can I convert my method so it runs under LINQ to Entities?