public void Update(IMetabase metabase, PlanFile plans) { var updateContext = new UpdateContext {Instructions = this, Metabase = metabase}; var plan = plans.Plan(ExtractName); ExtractName = plan.Name; Plan = plan.GetPlan(updateContext); }
protected override void FillIn(PlanPart parent, UpdateContext context) { ParentTable = parent.Table; ParentElementName = parent.ElementName; if (String.IsNullOrEmpty(ForeignKey)) ForeignKey = ElementName + Table.PrimaryKey.Name; }
protected override void FillIn(PlanPart parent, UpdateContext context) { base.FillIn(parent, context); ExtractName = context.Instructions.ExtractName; IdsToExtract = context.Instructions.IdsToExtract; DiscriminatorColumn = Table.Columns.FirstOrDefault(x => x.IsNamed(Discriminator)) ?? Table.PrimaryKey; }
protected override void FillIn(PlanPart parent, UpdateContext context) { base.FillIn(parent, context); if (String.IsNullOrEmpty(LookupColumn)) { LookupColumn = new[] { "Code", "Name" } }
protected override void FillIn(PlanPart parent, UpdateContext context) { if (String.IsNullOrWhiteSpace(ForeignKey)) { ForeignKey = parent.Table.Name + parent.Table.PrimaryKey.Name; } Ignore(ForeignKey); base.FillIn(parent, context); }
protected override void FillIn(PlanPart parent, UpdateContext context) { ParentTable = parent.Table; ParentElementName = parent.ElementName; if (String.IsNullOrEmpty(ForeignKey)) { ForeignKey = ElementName + Table.PrimaryKey.Name; } }
public void Update(IMetabase metabase, PlanFile plans) { var updateContext = new UpdateContext { Instructions = this, Metabase = metabase }; var plan = plans.Plan(ExtractName); ExtractName = plan.Name; Plan = plan.GetPlan(updateContext); }
public void Update(PlanPart parent, UpdateContext context) { //Console.WriteLine("Updating {0}", TableName); Table = context.Metabase.Table(TableName); Columns = Table.Columns; Ignore(Columns.Where(x => x.Insertable() == false).Select(x => x.Name).ToArray()); Ignore(Table.PrimaryKey); FillIn(parent, context); foreach (var child in Children) { child.Update(this, context); } }
public PlanPart GetPlan(UpdateContext updateContext) { var parts = PlanPart.Parse(Segments); foreach (var part in parts) { part.Update(null, updateContext); } if (parts.Count() > 1) { Console.WriteLine("Multi-part plans aren't supported (Yet!)"); } return(parts.FirstOrDefault()); }
protected override void FillIn(PlanPart parent, UpdateContext context) { base.FillIn(parent, context); if (String.IsNullOrEmpty(LookupColumn)) LookupColumn = new[] { "Code", "Name"}.FirstOrDefault(x => Columns.Any(y => y.IsNamed(x))); if(String.IsNullOrWhiteSpace(LookupColumn)) { throw new Exception("No columns specified for lookup!"); } var lookups = Regex.Split(LookupColumn, @"\s").Select(x => x.Trim()).ToArray(); var ignored = Columns.Where(x => lookups.All(y => x.IsNamed(y) == false)); Ignore(ignored.ToArray()); parent.Ignore(ForeignKey); }
private static IEnumerable <PlanPart> Parse(Segment segment, PlanPart parent) { var parts = new List <PlanPart>(); if (parent == default(PlanPart)) { parts.AddRange(RootPlanPart.Parse(segment.Text)); } else { var text = segment.Text.Substring(1); var prefix = segment.Text[0]; switch (prefix) { case '@': parts.AddRange(LookupPart.Parse(text)); break; case '<': parts.AddRange(HasManyPart.Parse(text)); break; case '>': parts.AddRange(HasOnePart.Parse(text)); break; default: Console.Error.WriteLine("Invalid: " + segment.Text); break; } } foreach (var part in parts) { part.Children = segment.SubSegments.SelectMany(x => Parse(x, part)).ToArray(); } return(parts); }
protected PlanPart() { Columns = new ColumnMeta[0]; Children = new PlanPart[0]; }
private static IEnumerable<PlanPart> Parse(Segment segment, PlanPart parent) { var parts = new List<PlanPart>(); if (parent == default(PlanPart)) { parts.AddRange(RootPlanPart.Parse(segment.Text)); } else { var text = segment.Text.Substring(1); var prefix = segment.Text[0]; switch (prefix) { case '@': parts.AddRange(LookupPart.Parse(text)); break; case '<': parts.AddRange(HasManyPart.Parse(text)); break; case '>': parts.AddRange(HasOnePart.Parse(text)); break; default: Console.Error.WriteLine("Invalid: " + segment.Text); break; } } foreach (var part in parts) { part.Children = segment.SubSegments.SelectMany(x => Parse(x, part)).ToArray(); } return parts; }
public void Update(PlanPart parent, UpdateContext context) { //Console.WriteLine("Updating {0}", TableName); Table = context.Metabase.Table(TableName); Columns = Table.Columns; Ignore(Columns.Where(x => x.Insertable() ==false).Select(x => x.Name).ToArray()); Ignore(Table.PrimaryKey); FillIn(parent, context); foreach (var child in Children) child.Update(this, context); }
protected override void FillIn(PlanPart parent, UpdateContext context) { if (String.IsNullOrWhiteSpace(ForeignKey)) ForeignKey = parent.Table.Name + parent.Table.PrimaryKey.Name; Ignore(ForeignKey); base.FillIn(parent, context); }
protected virtual void FillIn(PlanPart parent, UpdateContext context) { }
protected override void FillIn(PlanPart parent, UpdateContext context) { base.FillIn(parent, context); parent.Ignore(ForeignKey); }