public void New()
        {
            ForeignViewModel model = IoC.Get <ForeignViewModel>();

            model.EntityId = Entity.Id;
            Foreigns.Add(model);
        }
 public void Init()
 {
     CodeForeign[] foreigns = new CodeForeign[0];
     _provider.ExecuteScopedWork(provider =>
     {
         IDataContract contract = provider.GetRequiredService <IDataContract>();
         foreigns = contract.CodeForeigns.Where(m => m.EntityId == Entity.Id).ToArray();
     });
     Foreigns.Clear();
     foreach (CodeForeign foreign in foreigns)
     {
         ForeignViewModel model = _provider.GetRequiredService <ForeignViewModel>();
         model = foreign.MapTo(model);
         Foreigns.Add(model);
     }
 }