private void btnSelectUser_Click(object sender, RoutedEventArgs e) { var repository = new SystemUserRepository(_service); Func <string, Task <IEnumerable <SystemUser> > > getter = (string filter) => repository.GetUsersAsync(filter, new ColumnSet( SystemUser.Schema.Attributes.domainname , SystemUser.Schema.Attributes.fullname , SystemUser.Schema.Attributes.businessunitid , SystemUser.Schema.Attributes.isdisabled )); IEnumerable <DataGridColumn> columns = SystemUserRepository.GetDataGridColumn(); var form = new WindowEntitySelect <SystemUser>(_iWriteToOutput, _service.ConnectionData, SystemUser.EntityLogicalName, getter, columns); if (!form.ShowDialog().GetValueOrDefault()) { return; } if (form.SelectedEntity == null) { return; } var user = form.SelectedEntity; this._impersonatingUser = user.ToEntityReference(); txtBRunInUserContext.Text = !string.IsNullOrEmpty(user.FullName) ? user.FullName : user.DomainName; }