-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core]: Re-enable the QueryRecursive<T> operation. #263
Comments
This is using the following SQLs:
The client application will then do the mappings accordingly. |
@mikependon This is a much needed feature that is not available in most of the ORM out there. I'm glad that you brought this in. Will this support multiple joins (more than 2 tables)? If so, is there any limit on the number of tables that can be joint? |
TBH, this is an initial feature that I removed, because I introduced the QueryMultiple and ExecuteQueryMultiple operation. However, there are some scenarios that this method needs to be introduced. I have to do recode of this one from scratch (all over again) - the old codes were purged already. RE: No of tables that can be joint. Definitely, it can join multiple tables more than 2. There is a what we called cyclomatic problem here, as the child of the 5th table could be a parent of the 2nd table. In the old solution, you have to introduce the depth of the cycles. So the call would be something like this.
Or, could extend the existing one.
|
Why implement the loading with a join? You could minimize the duplicate column information in the result query by loading the information with a multi query like this:
Thanks |
@mdissel - thank you for this insight. It's been awhile since I wrote this enablement story. Anyway, QueryRecursive was first introduced in RepoDb before the Multiple Query. But I tend to remove it due to the fact that multiple query is a much more optimal as it is easier to control the implementations (developers POV). That's also what you recommended here. The purpose of this story is all about splitting the query result into a Parent-Child classes, to make sure that the we can get the information needed with only a single SQL Execution. Though, it is being pushed by the community to us, but it is already pre-assessed by us and decided not to introduce it for now. This is also the reason why we do not have JOINs in RepoDb up until now. The reason is, 99% of the problem is on the JOINs. |
But I do think it's a great addition if RepoDb has support for:
and that is translated into sql by RepoDb into:
or
|
@mdissel - it is a thing that is competing against Entity Framework which is really against our ideology. Actually, what you requested is can be done by using (var connection = new SqlConnection(ConnectionString))
{
var customerId = 10045;
var result = connection.QueryMultiple<Customer, Orders, Address)(customer => customer.Id = customerId,
order => order.CustomerId == customerId,
address => address.CustomerId == customerId);
var customer = result.Item1.FirstOrDefault();
var orders = result.Item2.AsList();
var address = result.Item3.AsList();
// Process the 'customer', 'orders' and 'address' variables here
} I guess, this is exactly what you are looking based on your query intentions. It will execute the following queries.
It just a different way, but it does the same. But is more optimal since you can control the hints (TBH). Hope that helps! |
Yes, my simple sample can be solved, but not if it's slightly more complex, like filtering on a customer property that is not part of the order or address entity.
|
Yes, you are correct there. What the |
The codes below must be supported.
Entity Class:
Operation Call:
The text was updated successfully, but these errors were encountered: