question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Joining two repos.GetAll() using where clause.

See original GitHub issue

We are using ABP to upgrade an old system which contains a lot of embedded SQL in code, and we want to translate the SQL text into C# query expression as much as possible.

The old SQL code used where clause to join tables, but ABP seems not support it…

We know we can use join ... on ... equals in ABP, like this:

var records = from user in userRepo.GetAll()
                   join userRole in userRoleRepo.GetAll() on user.Id equals userRole.userId
                    ...

But if we want to translate the SQL like this:

var records = from user in userRepo.GetAll()
                  from userRole in userRoleRepo.GetAll()
                  where user.Id == userRole.UserId
                  ...

It throws LINQ to Entities does not recognize the method 'System.Linq.IQueryable``1[UserRole] GetAll()' method, and this method cannot be translated into a store expression.

So I can only use join ... on .. equals to join tables in ABP?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
hikalkancommented, Apr 18, 2017

Let it be open. I added to it backlog to consider to convert GetAll to a property.

1reaction
hikalkancommented, Apr 17, 2017

If this is a general problem and adding a property helps to overcome these problems, we may consider to add a property to IRepository which returns IQueryable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SharpRepository - Join Between Two Repositories
1 Answer. There is a Join method on the repository that is similar to a LINQ Join statement and will let you join...
Read more >
Repository Pattern and Joined Queries
Joins are for correlating data sets with multiple records. That's not what you have here. Do you have a more concrete, real-world example...
Read more >
How to Use Multiple Inner Joins in SQL
To join two tables in SQL, you add the first table to the FROM clause, then add a join keyword (such as Inner...
Read more >
4 Common Mistakes with the Repository Pattern
Nothing! Your repositories should return domain objects. So, the GetOrders() method should return an IEnumerable. With this, the second example ...
Read more >
1. Working with Spring Data Repositories
The first configuration example will try to look up a class com.acme.repository.UserRepositoryImpl to act as custom repository implementation, where the second ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found