public static IRepository Init(this IRepository repository) { foreach (var entity in repository.Query <DbEntity>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityByInt>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityAsGuid>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityReference>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityItem>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityQuery>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityReference>()) { repository.Delete(entity); } foreach (var entity in repository.Query <DbEntityQueryAsItem>()) { repository.Delete(entity); } repository.Flush(); Pleasure.Do10((i) => repository.Save(Pleasure.Generator.Invent <DbEntityQuery>(dsl => dsl.GenerateTo(r => r.Reference) .Callback(query => { var item = Pleasure.Generator.Invent <DbEntityQueryAsItem>(factoryDsl => factoryDsl.Tuning(r => r.Parent, query)); query.Items.Add(item); })))); repository.Flush(); Pleasure.Sleep100Milliseconds(); // wait for apply data base. return(repository); }