Ho la seguente istruzione linq:
( from apiKey in context.Set<ApiKey>()
join application in context.Set<Application>() on apiKey.User equals application.User
join paymentGateway in context.Set<PaymentGateway>() on apiKey.User equals paymentGateway.User
where apiKey.Key == secureRequest.ApiKey
where application.Secret == secureRequest.ApplicationSecret
where paymentGateway.Id == secureRequest.PaymentGatewayId
select apiKey ).AnyAsync();
Ma quale per quanto ne so è corretto ma quando eseguo il codice ottengo il seguente errore.
Expression of type 'System.Collections.Generic.IEnumerable`1[System.Data.Common.DbDataReader]' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable`1[Microsoft.Data.Entity.Query.QuerySourceScope`1[DomainModel.PaymentGateway]]' of method 'System.Collections.Generic.IEnumerable`1[Microsoft.Data.Entity.Query.QuerySourceScope] _Join[QuerySourceScope,QuerySourceScope`1,User,QuerySourceScope](System.Collections.Generic.IEnumerable`1[Microsoft.Data.Entity.Query.QuerySourceScope], System.Collections.Generic.IEnumerable`1[Microsoft.Data.Entity.Query.QuerySourceScope`1[DomainModel.PaymentGateway]], System.Func`2[Microsoft.Data.Entity.Query.QuerySourceScope,PaymentGatewayWrapper.DomainModel.User], System.Func`2[Microsoft.Data.Entity.Query.QuerySourceScope`1[PaymentGatewayWrapper.DomainModel.PaymentGateway],PaymentGatewayWrapper.DomainModel.User], System.Func`3[Microsoft.Data.Entity.Query.QuerySourceScope,Microsoft.Data.Entity.Query.QuerySourceScope`1[DomainModel.PaymentGateway],Microsoft.Data.Entity.Query.QuerySourceScope])'
Qualsiasi puntatore nella giusta direzione sarebbe fantastico, grazie.
Dopo alcune ricerche ho scoperto che è l'Any a causare questo errore. Quindi con il seguente:
( from apiKey in context.Set<ApiKey>()
join application in context.Set<Application>() on apiKey.User equals application.User
join paymentGateway in context.Set<PaymentGateway>() on apiKey.User equals paymentGateway.User
where apiKey.Key == secureRequest.ApiKey
where application.Secret == secureRequest.ApplicationSecret
where paymentGateway.Id == secureRequest.PaymentGatewayId
select apiKey ).ToListAsync();
Ottengo questo errore:
The multi-part identifier "application.Secret" could not be bound.
The multi-part identifier "paymentGateway.Id" could not be bound.
Se qualcuno sa qual è il problema, ma non credo che l'EF 7 supporti ancora unirsi correttamente
Come so, il Join dovrebbe essere sui tipi primitivi. nel tuo join sembra che tu ti unisca per oggetto User
ma dovresti invece fare il join per UserId
.
( from apiKey in context.Set<ApiKey>()
join application in context.Set<Application>() on apiKey.UserId equals application.UserId
join paymentGateway in context.Set<PaymentGateway>() on apiKey.UserId equals paymentGateway.UserId
where apiKey.Key == secureRequest.ApiKey
where application.Secret == secureRequest.ApplicationSecret
where paymentGateway.Id == secureRequest.PaymentGatewayId
select apiKey ).AnyAsync();