Krishna Veni Ответов: 1

Аргумент типа для метода' compiler.compile ' не может быть выведен из использования.попробуйте явно указать аргумент типа


public static Func<TAGEntities, BusinessAddress, CustomerMerchant, Customer, User, IQueryable<BaseBusinessAddressModel>> GetOrdersQuery =

CompiledQuery.Compile((TAGEntities db, BusinessAddress address, CustomerMerchant merchant, Customer cus, User user) =>(db)=>

(from b in db.BusinessAddresses.Where(PredicateBuilder.True<BusinessAddress>())
 join cm in db.CustomerMerchants on address.BusinessId equals merchant.BusinessId
 join c in db.Customers on merchant.CustomerId  equals c.Id
 join u in db.Users on cus.UserId equals cus.Id
 select new  BaseBusinessAddressModel
 {
     Id = b.Id,
     BusinessId = b.BusinessId,
     BusinessAddressTypeId = b.BusinessAddressTypeId,
     BranchCode = b.BranchCode,
     AddressLine1 = b.AddressLine1,
     -------------=-----------
     -------------=-------------
     LastUpdated = b.LastUpdated,
     IsDeleted = b.IsDeleted,
     LogiName = u.LoginName,
     TimeZone = b.TimeZone
}


Ошибка произошла при использовании метода compile() в запросе.
Пожалуйста, помогите мне.
Спасибо....

Что я уже пробовал:

public static Func<TAGEntities, BusinessAddress, CustomerMerchant, Customer, User, IQueryable<BaseBusinessAddressModel>> GetOrdersQuery =

CompiledQuery.Compile((TAGEntities db, BusinessAddress address, CustomerMerchant merchant, Customer cus, User user) =>(db)=>

(from b in db.BusinessAddresses.Where(PredicateBuilder.True<BusinessAddress>())
 join cm in db.CustomerMerchants on address.BusinessId equals merchant.BusinessId
 join c in db.Customers on merchant.CustomerId  equals c.Id
 join u in db.Users on cus.UserId equals cus.Id
 select new  BaseBusinessAddressModel
 {
     Id = b.Id,
     BusinessId = b.BusinessId,
     BusinessAddressTypeId = b.BusinessAddressTypeId,
     BranchCode = b.BranchCode,
     AddressLine1 = b.AddressLine1,
     -------------=-----------
     -------------=-------------
     LastUpdated = b.LastUpdated,
     IsDeleted = b.IsDeleted,
     LogiName = u.LoginName,
     TimeZone = b.TimeZone
}


Ошибка произошла при использовании метода compile() в запросе.

F-ES Sitecore

Вы должны указать типы аргументов и ожидаемый результат в угловых скобках после метода компиляции.

Compiledquery на.Компиляции&ЛТ;ArgType1, ArgType2, параметром resulttype, имеющим значение&ГТ;(...)

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ef/language-reference/compiled-queries-linq-to-entities

Не зная ни одного из типов, которые вы используете, трудно дать точный ответ.

Gerry Schmitz

Затем попробуйте сделать это "без компиляции".

1 Ответов

Рейтинг:
1

Richard Deeming

Глядя на документацию, это должно быть так:

public static Func<TAGEntities, BusinessAddress, CustomerMerchant, Customer, User, IQueryable<BaseBusinessAddressModel>> GetOrdersQuery =
    CompiledQuery.Compile<TAGEntities, BusinessAddress, CustomerMerchant, Customer, User, IQueryable<BaseBusinessAddressModel>>((db, address, merchant, cus, user) =>
        from b in db.BusinessAddresses.Where(PredicateBuilder.True<BusinessAddress>())
        join cm in db.CustomerMerchants on address.BusinessId equals merchant.BusinessId
        join c in db.Customers on merchant.CustomerId  equals c.Id
        join u in db.Users on cus.UserId equals cus.Id
        select new  BaseBusinessAddressModel
        {
            Id = b.Id,
            BusinessId = b.BusinessId,
            BusinessAddressTypeId = b.BusinessAddressTypeId,
            BranchCode = b.BranchCode,
            AddressLine1 = b.AddressLine1,
            ...
            LastUpdated = b.LastUpdated,
            IsDeleted = b.IsDeleted,
            LogiName = u.LoginName,
            TimeZone = b.TimeZone
        });
Скомпилированные запросы (LINQ to Entities) - ADO.NET | Microsoft Docs[^]