public static ExchangePvp CreateNew(int depth = 0) { rt.atl.model.atl.ExchangePvp entity = new rt.atl.model.atl.ExchangePvp(); entity.StatementId = "Test Test T"; entity.IsExport = true; entity.Error = "Test Test "; using (rt.atl.business.manager.IPrzbufManager przbufManager = ObjectFactory.GetInstance <IPrzbufManager>()) { var all = przbufManager.GetAll(1); Przbuf entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = PrzbufTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.PrzBuff = entityRef; } return(entity); }