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

Add column ordering to What's New #3503

Merged
merged 2 commits into from
Oct 21, 2021
Merged

Conversation

ajcvickers
Copy link
Member

No description provided.

@ajcvickers ajcvickers requested a review from a team October 21, 2021 17:07
Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth mentioning that in some scenarios you need to use HasColumnOrder to avoid conflicts.

class Order
{
    public Address BillingAddress { get; set; }
    public Address ShippingAddress { get; set; }
}

class Address
{
    // Conflict! Use HasColumnOrder to configure BillingAddress and ShippingAddress separeately
    [Column(Order = 1)]
    public string Line1 { get; set; }

    public string Line2 { get; set; }
}

This example also shows how the same `ColumnAttribute` can be used to specify both the column name and order.

> [!IMPORTANT]
> Note that, in the general case, most databases only support ordering columns when the table is created. This means that the column order attribute cannot be used to re-order columns in an existing table. One notable exception to this is SQLite, where migrations will rebuild the entire table with new column orders.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 Only by coincidence, I assure you.

@ajcvickers
Copy link
Member Author

@bricelam Added a fluent API example, in case you want to take a look.

@ajcvickers ajcvickers merged commit 1e4182c into main Oct 21, 2021
@ajcvickers ajcvickers deleted the WhetherItsOffOrOnOrOnOrOffOrOn1020 branch October 21, 2021 18:55
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

Successfully merging this pull request may close these issues.

2 participants