As a result of the linq query. CalcMethod and WalkingLineMeasure properties are Enum - I try to parse string values from database but get an exception:
System.NotSupportedException: LINQ to Entities does not recognize the method 'AppForSellers.Models.BusinessLogic.SpiralStairs.Models.DiamDivide ParseDiamDivide' method, and this method cannot be translated into a store expression.
public List<StandardEnt> ListStandardsWithMethodList()
{
var listModel =
(
from dane in _dbContext.Standard
join kraj in _dbContext.CountryStandard
on dane.IdCountryStandard equals kraj.IdCountryStandard
join opcja in _dbContext.MeasureDiameterOption
on dane.IdStandard equals opcja.IdStandard
join metoda in _dbContext.MeasureDiameterMethod
on opcja.IdMeasureDiameterMethod equals metoda.IdMeasureDiameterMethod
join sposob in _dbContext.WalkingLineRadius
on opcja.IdWalkingLineRadius equals sposob.IdWalkingLineRadius
join linia in _dbContext.CalcMethodType
on sposob.IdCalcMethodType equals linia.IdCalcMethodType
join wyznaczanie in _dbContext.WalkingLineMeasure
on sposob.IdWalkingLineMeasure equals wyznaczanie.IdWalkingLineMeasure
select new StandardEnt()
{
IdStandard = dane.IdStandard,
IdCountryStandard = dane.IdCountryStandard,
StandardName = dane.StandardName,
MaxStepDeep = (double)dane.MaxStepDeep,
MinStepDeep = (double)dane.MinStepDeep,
MaxStepWidth = (double)dane.MaxStepWidth,
WidthLimit = (double)dane.WidthLimit,
StartOverlap = (double)dane.StartOverlap,
InternalHandrailMaxRadius = (double)dane.InternalHandrailMaxRadius,
PrimaryCalcMethod = (from metody in _dbContext.MeasureDiameterOption
where dane.IdStandard == metody.IdStandard && metody.MeasureDiameterMethod.CalcMethodName == "PrimaryCalcMethod"
select new MeasureDiameterMethodEnt()
{
IdMeasureDiameterOption = opcja.IdMeasureDiameterOption,
Description = opcja.Description,
IdMeasureDiameterMethod = metoda.IdMeasureDiameterMethod,
IdWalkingLineRadius = sposob.IdWalkingLineRadius,
IdCalcMethodType = linia.IdCalcMethodType,
IdWalkingLineMeasure = wyznaczanie.IdWalkingLineMeasure,
CalcMethod = Enum.Parse<DiamDivide>(linia.CalcMethodNameType),
WalkingLineMeasure = Enum.Parse<WalkingLineMeasureMethod>(wyznaczanie.WalkingLineMeasureName),
CalcMethodName = metoda.CalcMethodName,
FirstWidth = (double)sposob.FirstWidth,
SecondWidth = (double)sposob.SecondWidth
}).FirstOrDefault(),
SecondaryCalcMethod = (from metody in _dbContext.MeasureDiameterOption
where dane.IdStandard == metody.IdStandard && metody.MeasureDiameterMethod.CalcMethodName == "SecondaryCalcMethod"
select new MeasureDiameterMethodEnt()
{
IdMeasureDiameterOption = opcja.IdMeasureDiameterOption,
Description = opcja.Description,
IdMeasureDiameterMethod = metoda.IdMeasureDiameterMethod,
IdWalkingLineRadius = sposob.IdWalkingLineRadius,
IdCalcMethodType = linia.IdCalcMethodType,
IdWalkingLineMeasure = wyznaczanie.IdWalkingLineMeasure,
CalcMethod = Enum.Parse<DiamDivide>(linia.CalcMethodNameType),
WalkingLineMeasure = Enum.Parse<WalkingLineMeasureMethod>(wyznaczanie.WalkingLineMeasureName),
CalcMethodName = metoda.CalcMethodName,
FirstWidth = (double)sposob.FirstWidth,
SecondWidth = (double)sposob.SecondWidth
}).FirstOrDefault()
}
).ToList();
return listModel;
}