Skip to content

Commit

Permalink
Sorted properties from custom context (#57)
Browse files Browse the repository at this point in the history
* Sorted properties from custom context
Fixed typo in ConnectionDialog label

* Added ordering of columns
  • Loading branch information
RoyChase authored Nov 21, 2021
1 parent b5adac6 commit ecb7a4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/ConnectionDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<Label Padding="0,3,0,3" DockPanel.Dock="Right">
<Hyperlink Click="ChooseType">Choose...</Hyperlink>
</Label>
<Label Padding="1,3,1,3">Full name of custome type</Label>
<Label Padding="1,3,1,3">Full name of custom type</Label>
</DockPanel>
<TextBox Grid.Row="3" Text="{Binding CustomTypeName}" />

Expand Down
11 changes: 8 additions & 3 deletions Source/SchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ public TableInfo(PropertyInfo propertyInfo)
}

public IEnumerable<ExplorerItem> GetSchema()
{
{
var tables = _customType.GetProperties()
.Where(p =>
p.GetCustomAttributeLike<ObsoleteAttribute>() == null &&
p.PropertyType.MaybeChildOf(typeof(IQueryable<>)))
.OrderBy(p => p.Name)
.Select(p => new TableInfo(p))
.ToList();

Expand Down Expand Up @@ -123,9 +124,13 @@ ExplorerItem GetTable(ExplorerIcon icon, TableInfo table)
from ma in table.TypeAccessor.Members
let aa = ma.MemberInfo.GetCustomAttributeLike<AssociationAttribute>()
where aa == null
let ca = ma.MemberInfo.GetCustomAttributeLike<ColumnAttribute>()
let ca = ma.MemberInfo.GetCustomAttributeLike<ColumnAttribute>() as ColumnAttribute
let id = ma.MemberInfo.GetCustomAttributeLike<IdentityAttribute>()
let pk = ma.MemberInfo.GetCustomAttributeLike<PrimaryKeyAttribute>()
let pk = ma.MemberInfo.GetCustomAttributeLike<PrimaryKeyAttribute>()
orderby
ca == null ? 1 : ca.Order >= 0 ? 0 : 2,
ca?.Order,
ma.Name
where
ca != null && ca.IsColumn ||
pk != null ||
Expand Down

0 comments on commit ecb7a4a

Please sign in to comment.