Skip to content
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

AsyncQuery does not support multiple types for multi-POCO queries #609

Open
craysiii opened this issue Jun 14, 2021 · 0 comments
Open

AsyncQuery does not support multiple types for multi-POCO queries #609

craysiii opened this issue Jun 14, 2021 · 0 comments

Comments

@craysiii
Copy link

craysiii commented Jun 14, 2021

I am relatively new to using PetaPoco and have been enjoying it so far in the project I am working on.

I have been utilizing the Async versions of the query and fetch methods for data access so far. However, I am to the point now where I need to implement an multi-POCO query, and I am getting an error that only one type can be passed.

Is this intentional? I believe my options right now are to

  1. Query in a non-async fashion
  2. Perform multiple async queries

Example query I'm trying to accomplish:

var sql = Sql.Builder
                .Append("SELECT \"PrimaryCommand\".*, \"PrimaryCommandDependency\".*")
                .Append("FROM \"PrimaryCommand\"")
                .Append("LEFT JOIN \"PrimaryCommandDependency\" ON \"PrimaryCommand\".\"Id\" = \"PrimaryCommandDependency\".\"PrimaryCommandId\"")
                .Append($"WHERE \"PrimaryCommand\".\"Id\" = '{id}'");

            return _db.connection.Query<PrimaryCommand, PrimaryCommandDependency, PrimaryCommand>((pc, pcd) => {
                pc.Dependencies.Add(pcd); return pc;
            }, sql).FirstOrDefault();

Thanks for reading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant