次のクエリに重大な問題があります。
context.CharacteristicMeasures
        .FirstOrDefault(cm => cm.Charge == null &&
                              cm.Characteristic != null &&
                              cm.Characteristic.Id == c.Id &&
                              cm.Line != null &&
                              cm.Line.Id == newLine.Id &&
                              cm.ShiftIndex != null &&
                              cm.ShiftIndex.Id == actShiftIndex.Id &&
                              (newAreaItem == null ||
                                  (cm.AreaItem != null &&
                                   cm.AreaItem.Id == newAreaItem.Id)));
TargetException: Non-static method requires a target  newAreaItem が nullの場合に取得します。newAreaItem が null でない場合は、NotSupportedException: Unable to create a constant value of type 'PQS.Model.AreaItem'. Only primitive types or enumeration types are supported in this context.
null であるかどうかは既に確認済みです: c、newLine、actShiftIndex の 3 つの変数はすべて null ではなく、ID にアクセスできます。
わかりません...助けてください。
さらに情報が必要な場合は、お気軽にお問い合わせください...
アップデート
をなくすことはできましたNotSupportedExceptionが、newAreaItemIsNull が true の場合でも TargetException が発生します。:/
bool newAreaItemIsNull = (newAreaItem == null);
var mc = context.CharacteristicMeasures
                .FirstOrDefault(cm => cm.Charge == null &&
                                      cm.Characteristic != null &&
                                      cm.Characteristic.Id == c.Id &&
                                      cm.Line != null &&
                                      cm.Line.Id == newLine.Id &&
                                      cm.ShiftIndex != null &&
                                      cm.ShiftIndex.Id == actShiftIndex.Id &&
                                      (newAreaItemIsNull ||
                                          (cm.AreaItem != null &&
                                           cm.AreaItem.Id == newAreaItem.Id)));
アップデート
ついにやりました。newAreaItem(IsNull)どうやらDBモデルにないのでクエリパースが解析できないらしい!? クエリを分割する必要があります..
bool newAreaItemIsNull = (newAreaItem == null);
MeasureCharacteristic mc;
if (newAreaItemIsNull)
   mc = context.CharacteristicMeasures
               .FirstOrDefault(cm => cm.Charge == null &&
                                     cm.Characteristic != null &&
                                     cm.Characteristic.Id == c.Id &&
                                     cm.Line != null &&
                                     cm.Line.Id == newLine.Id &&
                                     cm.ShiftIndex != null &&
                                     cm.ShiftIndex.Id == actShiftIndex.Id);
else
   mc = context.CharacteristicMeasures
               .FirstOrDefault(cm => cm.Charge == null &&
                                     cm.Characteristic != null &&
                                     cm.Characteristic.Id == c.Id &&
                                     cm.Line != null &&
                                     cm.Line.Id == newLine.Id &&
                                     cm.ShiftIndex != null &&
                                     cm.ShiftIndex.Id == actShiftIndex.Id &&
                                     cm.AreaItem != null &&
                                     cm.AreaItem.Id == newAreaItem.Id);
誰かがより良い解決策を知っていますか?