Closed PatrykSzwer closed 5 years ago
Most important: System.ArgumentException: Expression 'b => b.From.Name' refers to a property that is not from type Inventory.ViewModels.TransferRow.
which is not true, since TransferRow has b.From.Name
The warning is not clear enough, but it's true. Name
is not a property of TransferRow
. It's a property of TransferRow_From
.
I think we should implement support for nested view-models since it is/will be really popular use-case
I think it's a good idea, but I don't know if we have enuogh time for this. It's not my decision
I just bumped on that problem.
My JSON:
{
"Id": "",
"Created": "",
"MainViewUri": "", /*this works*/
"MainView": { /*this is problematic*/
"Uri": ""
},
"DeleteTrigger$": 0
}
My C#:
public CompositionsPage()
{
this.CompositionsTable = new DataTableBuilder<CompositionsPageCompositionTableItem>()
.WithDataSource(DbLinq.Objects<HtmlViewComposition>().Where(x => x.NextVersion == null), data => data
.WithConverter(CompositionRow)
.WithFilter(new CompositionFilter()))
.WithColumns(columns =>
columns
.AddColumn(b => b.Created, column => column.DisplayName("Created at").Sortable().Filterable())
.AddColumn(b => b.MainViewUri, column => column.DisplayName("Main view").Sortable().Filterable())
.AddColumn(b => b.MainView.Uri, column => column.DisplayName("Main view").Sortable().Filterable())
)
.Build();
}
MainViewUri
and MainView.Uri
should bind equally well.
(MainViewUri
is just a getter for MainView.Uri
)
b => b.MainViewUri
works as desired but b => b.MainView.Uri
throws:
System.ArgumentException
HResult=0x80070057
Message=Expression 'b => b.MainView.Uri' refers to a property that is not from type BlendingEditor.Website.ViewModels.CompositionsPageCompositionTableItem.
Source=Starcounter.Uniform
StackTrace:
at Starcounter.Uniform.Builder.DataColumnBuilder`1.AddColumn[TColumn](Expression`1 propertySelector, Action`1 configure)
at BlendingEditor.Website.ViewModels.CompositionsPage.<>c.<.ctor>b__1_2(DataColumnBuilder`1 columns) in W:\repo\HeadsOmni\src\Blending.Mapper\Blending\src\BlendingEditor\Website\ViewModels\CompositionsPage.json.cs:line 24
at Starcounter.Uniform.Builder.DataTableBuilder`1.WithColumns(Action`1 configure)
at BlendingEditor.Website.ViewModels.CompositionsPage..ctor() in W:\repo\HeadsOmni\src\Blending.Mapper\Blending\src\BlendingEditor\Website\ViewModels\CompositionsPage.json.cs:line 19
at BlendingEditor.Website.Api.MainHandlers.<>c__DisplayClass0_1.<Register>b__26() in W:\repo\HeadsOmni\src\Blending.Mapper\Blending\src\BlendingEditor\Website\Api\MainHandlers.cs:line 156
at Starcounter.Db.<>c__DisplayClass50_0`1.<Scope>b__0()
at Starcounter.Internal.TransactionManager.Scope(TransactionHandle handle, Action action)
at Starcounter.Transaction.Scope(Action action)
at Starcounter.Db.Scope(Action action, Boolean isReadOnly)
@PatrykSzwer could you please investigate. Perhaps @miyconst can help out.
I added support for single-level nested properties in the 2.5.0 version. There is also PR for the documentation about the new feature here https://github.com/Starcounter/Starcounter.Uniform/pull/29 but I think this issue can be already closed.
I have situation like that: View-model for
transfer
row:Data-model:
Uni-data-table implementation:
When I try to run this I'm reciving exception:
Most important:
System.ArgumentException: Expression 'b => b.From.Name' refers to a property that is not from type Inventory.ViewModels.TransferRow.
which is not true, since
TransferRow
hasb.From.Name
. I think we should implement support for nested view-models since it is/will be really popular use-case, and right now user can't have automatically generated filtering and sorting for those columns. It is possible to workaround this but I'm not sure if it should be necessary.CC: @joozek78