У меня есть класс, который используется для LINQ
методов расширения.Я получаю System.TypeInitializationException
из следующего класса:
public static class CarLib {
private readonly static IOPTS_EFEntities Context = new myEFEntities();
public IQueryable<Transmission> GetTransmissions(this Car car, IEFEntities context = null) {
if (context == null)
context = Context;
return SelectCarWithTransmissionCompiled(car, context);
}
public IQueryable<Tire> GetTires(this Car car, IEFEntities context=null) {
if (context == null)
context = Context;
return SelectTiresCompiled(car, context);
}
private static readonly Func<Car, IEFEntities, IQueryable<Transmission>> SelectTransmissionsCompiled = SelectTransmissions.Compile();
private static readonly Func<Car, IEFEntities, IQueryable<Tire>> SelectTiresCompiled = SelectTires.Compile();
private static readonly Expression<Func<Car, IEFEntities, IQueryable<Transmission>>> SelectTransmissions= (myCar,context) =>
from trans in context.Transmissions
where trans.CarId == myCar.Id
select trans;
private static readonly Expression<Func<Car, IEFEntities, IQueryable<Tire>>> SelectTires = (car,context) =>
from tire in context.Tires
where car.Id == tire.CarId
&& accused.Ssn.IsValidSsn()
&& !tire.Brand.IsNullEmptyOrWhitespace()
&& !tire.Diameter.IsNullEmptyOrWhitespace()
&& !tire.Weight.IsNullEmptyOrWhitespace()
&& tire.Price.IsPopulated()
select tire;
}