public ITableBuilder AddTable(ITableConfig table) { var builder = this.CreateTable(table); this.Expressions.Add(builder); return(builder); }
public ITableConfig Create(IConfig config, string identifier, ITableConfig leftTable, ITableConfig rightTable, TableFlags?flags) { var attribute = new TableAttribute() { Name = Conventions.RelationTableName(leftTable, rightTable), Identifier = identifier, }; if (string.IsNullOrEmpty(attribute.Identifier)) { attribute.Identifier = Conventions.RelationTableName(leftTable, rightTable); } if (!attribute.IsFlagsSpecified) { if (flags.HasValue) { attribute.Flags = flags.Value; } else { attribute.Flags = Defaults.Table.Flags; } } return((ITableConfig)this.Members.Invoke(this, "Create", new[] { leftTable.TableType, rightTable.TableType }, config, attribute.Identifier, attribute.Name, leftTable, rightTable, attribute.Flags)); }
public EntityGraphNode(Type entityType, IEntityGraphNode parent, ITableConfig table, IRelationConfig relation) { this.EntityType = entityType; this.Parent = parent; this.Table = table; this.Relation = relation; }
public IColumnConfig Create(ITableConfig table, IColumnSelector selector) { switch (selector.SelectorType) { case ColumnSelectorType.ColumnName: var property = PropertyResolutionStrategy.GetProperty(table.TableType, selector.ColumnName); if (property != null) { return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, property, selector.Flags)); } else { return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Flags)); } case ColumnSelectorType.Property: return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Property, selector.Flags)); case ColumnSelectorType.Expression: return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Expression, selector.Flags)); default: throw new NotImplementedException(); } }
public IEnumerable <IIndexConfig> GetIndexes(ITableConfig table) { var columns = new Dictionary <string, PendingIndex>(); var indexes = new List <IIndexConfig>(); foreach (var column in table.Columns) { if (column.Property == null) { continue; } var attribute = column.Property.GetCustomAttribute <IndexAttribute>(true); if (attribute == null) { continue; } if (!columns.ContainsKey(attribute.Name)) { columns[attribute.Name] = new PendingIndex(); } columns[attribute.Name].Columns.Add(column); if (attribute.IsFlagsSpecified) { columns[attribute.Name].Flags |= attribute.Flags; } } foreach (var key in columns.Keys) { var index = Factories.Index.Create(table, IndexConfig.By(columns[key].Columns, columns[key].Flags)); indexes.Add(index); } return(indexes); }
protected virtual void VisitRelation(ITableConfig table, IBinaryExpressionBuilder expression) { this.Builder.AppendFormat("{0} ", this.Database.QueryFactory.Dialect.JOIN); this.VisitTable(this.CreateTable(table)); this.Builder.AppendFormat("{0} ", this.Database.QueryFactory.Dialect.ON); this.Visit(expression); }
public override IQueryGraphBuilder Add(ITableConfig table) { var builder = default(IQueryGraphBuilder); foreach (var column in table.PrimaryKeys) { if (column.Flags.HasFlag(ColumnFlags.Generated) && column.ColumnType.IsNumeric) { if (builder == null) { builder = this.Build(); } builder.Output.AddParameter( SqlServerQueryParameter.Identity, DbType.Object, 0, 0, 0, ParameterDirection.Input, true, null, DatabaseQueryParameterFlags.None ); } } if (builder == null) { return(base.Add(table)); } return(this.Combine(new[] { base.Add(table), builder })); }
public IHtmlContent Render(ITableConfig <T> config, int entityCount) { List <TableNode> nodes = new List <TableNode>(); _config = config; _entityCount = entityCount; _containerId = _tableState.ContainerId; TableNode table = this.Table(); TableNode innerContainer = this.Container(nodes, table); if (_tableState.ContainerId != null) { KeyValuePair <string, ColumnConfig> column = _config.Columns.FirstOrDefault(c => c.Value.SortState.HasValue && c.Value.SortState != SortState.None && c.Key != _tableState.SortProp); // Reset sort state for any column that was initially sorted. if (column.Value != null) { column.Value.SortState = SortState.None; } } this.Caption(table); this.Header(table); this.Body(table); this.Footer(table); innerContainer.Element.InnerHtml.AppendHtml(string.Format(JsCode.Code, _containerId)); this.FilteringLinkTemplate(innerContainer); return(_nodeParser.Parse(nodes)); }
protected virtual IEntityGraphNode CreateNode(ITableConfig table, IEntityMapper mapper) { var node = (EntityGraphNode)this.Members.Invoke(this, "CreateNode", this.GetMapping(table).EntityType, table); node.Children = GetChildren(this, node, mapper); return(node); }
public static PropertyInfo GetLambdaProperty(this Expression expression, ITableConfig table) { if (table is IMappingTableConfig) { return(expression.GetLambdaProperty((table as IMappingTableConfig).LeftTable.TableType)); } return(expression.GetLambdaProperty(table.TableType)); }
public static void SetKey(ITableConfig table, object item, object key) { if (table.PrimaryKey == null) { throw new InvalidOperationException(string.Format("Table \"{0}\" does not have a valid primary key configuration.", table.TableName)); } table.PrimaryKey.Setter(item, key); }
public static bool HasKey(ITableConfig table, object item, out object key) { if (table.PrimaryKey == null) { throw new InvalidOperationException(string.Format("Table \"{0}\" does not have a valid primary key configuration.", table.TableName)); } return(IsKey(table.PrimaryKey, key = table.PrimaryKey.Getter(item))); }
internal TableBuilder(TableModel <T> model, ITableRenderer <T> renderer, IBuilderFactory builderFactory, ITableConfig <T> config) { _model = model; _renderer = renderer; _builderFactory = builderFactory; _config = config; }
public EntityStateDetector(IDatabase database, ITableConfig table, IDatabaseQueryComposer composer, ITransactionSource transaction = null) : this() { this.Database = database; this.Table = table; this.Composer = composer; this.Transaction = transaction; }
public EntityCompoundEnumerator(IDatabase database, ITableConfig table, IEntityMapper mapper, IEntityEnumeratorVisitor visitor) : this() { this.Database = database; this.Table = table; this.Mapper = mapper; this.Visitor = visitor; }
public ISchemaGraphBuilder Update(ITableConfig leftTable, ITableConfig rightTable, SchemaFlags flags) { var builder = this.Build(); builder.Alter.SetLeftTable(leftTable); builder.Alter.SetRightTable(rightTable); return(builder); }
public IIndexConfig Create(ITableConfig table, string identifier, IEnumerable <string> columnNames, IndexFlags?flags) { var columns = columnNames.Select( columnName => table.GetColumn(ColumnConfig.By(columnName, ColumnFlags.None)) ).Where(column => column != null); return(this.Create(table, identifier, columns, flags)); }
public IndexConfig(IConfig config, IndexFlags flags, string identifier, ITableConfig table, IEnumerable <IColumnConfig> columns) : this(config) { this.Flags = flags; this.Identifier = identifier; this.Table = table; this.Columns = columns; }
public void Check(ITableConfig config, IEnumerable <object> tableEntities) { if ((config.Paging.PageSize > 0 || config.Columns.Any(c => c.Value.SortState.HasValue) || config.Columns.Any(c => c.Value.Filtering.Threshold > 0)) && string.IsNullOrEmpty(config.Update.Url)) { throw(new Exception("Update url must be configured if using paging, sorting or filtering.")); } }
public virtual IQueryGraphBuilder Fetch(ITableConfig table) { var builder = this.Build(); builder.Output.AddColumns(table.Columns); builder.Source.AddTable(table); builder.Sort.AddColumns(table.PrimaryKeys); return(builder); }
public object CreateValue(ITableConfig table, IColumnConfig column, object item) { switch (column.ColumnType.Type) { case DbType.Guid: return(SequentialGuid.New()); } return(column.DefaultValue); }
public TableRenderer(TableModel <T> model, TableConfig config, TableState tableState, ITableNodeParser nodeParser) { _model = model; _config = config; _tableState = tableState; _entity = new T(); _nodeParser = nodeParser; }
public ISchemaGraphBuilder Delete(ITableConfig table, SchemaFlags flags) { var tables = default(HashSet <ITableConfig>); var indexes = default(HashSet <IIndexConfig>); var relations = default(HashSet <IRelationConfig>); this.GetSchema(table, out tables, out indexes, out relations, flags); return(this.OnDelete(tables, indexes, relations, flags)); }
public EntityCompoundPersister(IDatabase database, ITableConfig table, IEntityMapper mapper, IEntityPersisterVisitor visitor, ITransactionSource transaction = null) : this() { this.Database = database; this.Table = table; this.Mapper = mapper; this.Visitor = visitor; this.Transaction = transaction; }
protected virtual IEntityGraphMapping GetMapping(ITableConfig table) { var mapping = default(IEntityGraphMapping); if (!this.Mapping.TryGetValue(table, out mapping)) { mapping = this.Mapping[table] = new EntityGraphMapping(table); } return(mapping); }
public object Get(ITableConfig table) { var item = default(object); if (this.Buffer.TryGetValue(table, out item)) { return(item); } return(null); }
public virtual IQueryGraphBuilder Delete(ITableConfig table) { var builder = this.Build(); builder.Delete.Touch(); builder.Source.AddTable(table); builder.Filter.AddColumns(table.PrimaryKeys); builder.Filter.AddColumns(table.ConcurrencyColumns); return(builder); }
public bool HasKey(ITableConfig table, out object key) { key = this.Key(table); if (EntityKey.IsKey(table.PrimaryKey, key)) { return(true); } key = null; return(false); }
protected virtual bool TryGetTable(Expression expression, out ITableConfig result) { var type = expression.Type; if (type.IsGenericType) { type = type.GetGenericArguments()[0]; } result = this.Database.Config.GetTable(TableConfig.By(type)); return(result != null); }
public static ITableSelector By(string identifier, ITableConfig leftTable, ITableConfig rightTable, TableFlags?flags) { return(new TableSelector() { Identifier = identifier, LeftTable = leftTable, RightTable = rightTable, Flags = flags, SelectorType = TableSelectorType.Mapping }); }