This query returns 4 records (2x is IdStandard = 2) - I need 3 records with unique IdStandard and PrimaryCalcMethod and SecondaryCalcMethod methods. If the latter method is not present, the SecondaryCalcMethod property is to return null. How to change the linq query?
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.
What I have tried:
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,
IsActive = dane.IsActive,
NameCountry = kraj.NameCountryStandard,
FreeHeadSpace = (double)dane.FreeHeadSpace,
IsTlcStandard = dane.IsTlcStandard,
MinLandingSize = (double)dane.MinLandingSize,
MinStepHeight = (double)dane.MinStepHeight,
MaxStepHeight = (double)dane.MaxStepHeight,
MinConvinience = (double)dane.MinConvinience,
MaxConvinience = (double)dane.MaxConvinience,
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),
<code></code> WalkingLineMeasure = Enum.Parse<walkinglinemeasuremethod>(wyznaczanie.WalkingLineMeasureName),
CalcMethodName = metoda.CalcMethodName,
FirstWidth = (double)sposob.FirstWidth,
SecondWidth = (double)sposob.SecondWidth
}).FirstOrDefault()
}
).ToList();
return listModel;
}