Skip to content

Sorted properties from custom context #57

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

Merged
merged 2 commits into from
Nov 21, 2021

Conversation

RoyChase
Copy link
Contributor

Sorted properties from custom context
Fixed typo in ConnectionDialog label

Fixes #56

Fixed typo in ConnectionDialog label
@dnfadmin
Copy link

dnfadmin commented Apr 30, 2021

CLA assistant check
All CLA requirements met.

@MaceWindu MaceWindu added this to the 3.4.0 milestone May 1, 2021
Copy link
Contributor

@MaceWindu MaceWindu left a comment

Choose a reason for hiding this comment

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

Thanks. Will merge later when we are ready to release new version. Want to check if it is really random or use column ordinal

@RoyChase
Copy link
Contributor Author

RoyChase commented May 1, 2021

It's not column ordinal as it doesn't make a call to the database when generating the tree. From some test I am doing it looks to be in the order that the properties are in the source (which is logical) but I doesn't always seem to be this way as the context I was originally trying this with has the properties in alphabetic order. I don't have this to had today but I'll do some more tests to confrm this and that the fix actually works. Leave it with me.

@MaceWindu
Copy link
Contributor

Ah, you are right. Here we load columns using reflection.

Usually it is ordered by declaration order in source code due to implementation, but as it documented here it is not always true :)

@@ -54,6 +54,7 @@ public IEnumerable<ExplorerItem> GetSchema()
.Where(p =>
p.GetCustomAttributeLike<ObsoleteAttribute>() == null &&
p.PropertyType.MaybeChildOf(typeof(IQueryable<>)))
.OrderBy(p => p.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to sort by ColumnAttribute.Order for columns with HasOrder and by name for rest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original change will sort the tables. I'm still trying to sort the columns but I will honor the ColumnAttribute if the order is specified.

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure of helpful, but here we apply similar sorting for columns in create table based on Order: https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/SqlProvider/BasicSqlBuilder.cs#L1111

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tables and columns shold now sort by name honouring column attribute order if applicable

@MaceWindu MaceWindu merged commit ecb7a4a into linq2db:master Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Properties from custom assembly are in random order
3 participants