public IEnumerable <IDataTableAdapterVisitor> GetVisitors(IMasterDetailRowArguments masterDetailRowArguments) { var selectedItemType = masterDetailRowArguments.SelectedItem.GetType(); var detailAdapterItemType = masterDetailRowArguments.DataAdapter.UnderlyingTypeOfItem; var masterDetailConfiguration = _gridConfigurationProvider .GetGridConfigurationByType(selectedItemType) .FindRelationshipConfiguration(detailAdapterItemType); if (masterDetailRowArguments.DataAdapter is ILazyLoadedTableDataAdapter) { return(new List <IDataTableAdapterVisitor> { new LazyLoadingRouteParamVisitor(masterDetailConfiguration, masterDetailRowArguments, _propertyValueAccessorCache) }); } var filterVisitorType = typeof(FilterVisitor <>).MakeGenericType(detailAdapterItemType); var filterVisitor = Activator.CreateInstance(filterVisitorType, new object[] { masterDetailConfiguration, masterDetailRowArguments, _propertyValueAccessorCache }) as IDataTableAdapterVisitor; return(new List <IDataTableAdapterVisitor> { filterVisitor }); }
public ITableDataSet ConvertToMasterTableIfIsRequired(ITableDataSet tableDataSet) { if (tableDataSet is IMasterTableDataSet masterTableDataSet) { return(masterTableDataSet); } var entityConfiguration = gridConfigurationProvider.GetGridConfigurationByType(tableDataSet.UnderlyingTypeOfItem()); if (!entityConfiguration.IsMasterTable) { return(tableDataSet); } var masterDetailTableDataSetType = typeof(MasterDetailTableDataSet <>).MakeGenericType(tableDataSet.UnderlyingTypeOfItem()); var masterDetailTableDataSet = Activator.CreateInstance(masterDetailTableDataSetType, new object[] { tableDataSet, gridConfigurationProvider, tableDataAdapterProvider }) as IMasterTableDataSet; return(masterDetailTableDataSet); }
public override ITableDataSet GetTableDataSet(Action <TableDataSetOptions> configureDataSet) { var masterDetailRelation = gridConfigurationProvider .GetGridConfigurationByType(masterDetailRowArguments.SelectedItem.GetType()) .FindRelationshipConfiguration(UnderlyingTypeOfItem); if (masterDetailRelation.IsOwnCollection) { return(masterDetailRowArguments.DataAdapter.GetTableDataSet(configureDataSet)); } var clonedDataAdapter = masterDetailRowArguments.DataAdapter.Clone() as ITableDataAdapter; foreach (var visitor in detailDataAdapterVisitors.GetVisitors(masterDetailRowArguments)) { clonedDataAdapter.Accept(visitor); } return(clonedDataAdapter.GetTableDataSet(configureDataSet)); }
private IDataTableAdapterVisitor GetFilterVisitor(IMasterDetailRowArguments masterDetailRowArguments) { var selectedItemType = masterDetailRowArguments.SelectedItem.GetType(); var detailAdapterItemType = masterDetailRowArguments.DataAdapter.UnderlyingTypeOfItem; var masterDetailConfiguration = gridConfigurationProvider .GetGridConfigurationByType(selectedItemType) .FindRelationshipConfiguration(detailAdapterItemType); var constantValue = propertyValueAccessorCache .GetPropertyAccesor(selectedItemType) .GetValue(masterDetailRowArguments.SelectedItem, masterDetailConfiguration.MasterDetailConnection.MasterPropertyName); var parameter = Expression.Parameter(detailAdapterItemType, "x"); var member = Expression.Property(parameter, masterDetailConfiguration.MasterDetailConnection.ForeignPropertyName); var constant = Expression.Constant(constantValue); var body = Expression.Equal(member, constant); var filterVisitorType = typeof(FilterVisitor <>).MakeGenericType(detailAdapterItemType); var filterVisitor = Activator.CreateInstance(filterVisitorType, new object[] { body, parameter }) as IDataTableAdapterVisitor; return(filterVisitor); }