Skip to content

Commit

Permalink
use column attribute for query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Oct 27, 2024
1 parent c3807b8 commit 5d540f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/LoreSoft.Blazor.Controls/Query/QueryBuilderField.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq.Expressions;
using System.Reflection;

Expand Down Expand Up @@ -34,6 +35,8 @@ public class QueryBuilderField<TItem> : ComponentBase

public string Name { get; set; }

public string Column { get; set; }

public Type Type { get; set; }


Expand Down Expand Up @@ -144,6 +147,9 @@ private void UpdateProperty()
Name = memberInfo.Name;
Type = typeof(object);
}

var columnAttribute = memberInfo.GetCustomAttribute<ColumnAttribute>(true);
Column = columnAttribute != null ? columnAttribute.Name : Name;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<option value="">- Field -</option>
@foreach (var field in Fields)
{
<option @key="field" value="@field.Name">@field.CurrentTitle</option>
<option @key="field" value="@field.Column">@field.CurrentTitle</option>
}
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override void OnInitialized()

protected void FieldChanged()
{
Field = Fields.FirstOrDefault(f => f.Name == Filter.Field);
Field = Fields.FirstOrDefault(f => f.Column == Filter.Field);
QueryBuilder.Refresh();
}

Expand Down

0 comments on commit 5d540f9

Please sign in to comment.