private static string MakeIdList(DbTable table) { var re = Options.Do.Conventions; return string.Join(", ", table.PrimaryKeysExceptFk.Select(x => "{0} {1}".AsFormat(re.TypeFor(x), re.NameFor(x))).Union( table.KeyManyToOneRelations.Select(x => "{0} {1}".AsFormat(re.TypeFor(x), re.NameFor(x)))).ToArray()); }
public void Create(DbTable table) { var conventions = GetConventions(); var fileName = FileTemplate.AsFormat(conventions.NameFor(table)); SetTemplate(table); if (Overwrite || !Project.ExistsFile(fileName)) Project.AddNewFile(fileName, FileType, this.ToString()); }
protected override void SetTemplate(Simple.Metadata.DbTable table) { var opt = Options.Instance; var re = opt.Conventions; this.SetMany(new { re = re, table = table, opt = opt, classname = re.NameFor(table), count = new Func <IEnumerable, int>(x => x.Cast <object>().Count()), idlist = new Func <DbTable, string>(MakeIdList) }); }
protected abstract void SetTemplate(DbTable table);