protected virtual Expression VisitColumnDefinition(ColumnDefinitionExpression node) { var c = node.Column; Append("["); Append(c.ColumnName); Append("]", false); Append(c.ColumnType); if (c.ReferenceTable == null) { if (c.IsIdentity) { Append("IDENTITY(1,1)"); } if (!c.IsNullable) { Append("NOT"); } Append("NULL"); if (c.DefaultValue != null && !c.IsIdentity) { Append("DEFAULT"); Append(_dataEngine.GetLiteral(c.DefaultValue)); } } else { //TODO: use DbSet instead var pkFields = _dataEngine.ColumnMapper[c.ReferenceTable.BaseType].Where(cc => cc.IsIdentity).Select(cc => cc.ColumnName); if (!c.IsNullable) { Append("NOT NULL"); } Append("FOREIGN KEY REFERENCES"); Append(string.Format("{0}({1})", c.ReferenceTable.BaseType.GetTableAttribute().FullName, string.Join(",", pkFields))); } return(node); }
protected virtual Expression VisitColumnDefinition(ColumnDefinitionExpression node) { var c = node.Column; Append("["); Append(c.ColumnName); Append("]", false); Append(c.ColumnType); if (c.ReferenceTable == null) { if (c.IsIdentity) Append("IDENTITY(1,1)"); if (!c.IsNullable) Append("NOT"); Append("NULL"); if (c.DefaultValue != null && !c.IsIdentity) { Append("DEFAULT"); Append(_dataEngine.GetLiteral(c.DefaultValue)); } } else { //TODO: use DbSet instead var pkFields = _dataEngine.ColumnMapper[c.ReferenceTable.BaseType].Where(cc => cc.IsIdentity).Select(cc => cc.ColumnName); if (!c.IsNullable) Append("NOT NULL"); Append("FOREIGN KEY REFERENCES"); Append(string.Format("{0}({1})", c.ReferenceTable.BaseType.GetTableAttribute().FullName, string.Join(",", pkFields))); } return node; }