Skip to content

Updated example for Includes #564

Open
@Reddevildragg

Description

@Reddevildragg

Quick question around is there an updated example for the Includes function?

The documentation shows the function taking 1 parameter (which i assume is a query for the table you want to connect into

var books = db.Query("Books")
    .Include(db.Query("Authors")) // Assumes that the Books table have a `AuthorId` column
    .Get()

However version 2.3.7 the include function appears to take a minimum of 2 parameters for relationName and query, but also optional for foreignkey, localKey and is many.

Is there an example of how to pull this together under the new parameters.

What i have tried to far is as followed:

db.Query("User").Where("User.Id", index).Include("Project",db.Query("Projects"), "ProjectId", "Id", false).Get<User>();

Which runs but then when running the "Project" field within the User Class remains as Null, not sure if i have the request wrong or if the mapping is into a class is not working as i thought it may be. For this case my User Class has the following:

public int ProjectId { get; set; }
public Project Project { get; set; }

Project Id gets mapped, but not project

Thanks for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions