private static XtraBinding CreateXtraBindingSource(XOTableContext TableContext, IControllerProvider ControllerProvider, XtraBindingChildProperties ChildProperties)
        {
            object dataSource = ControllerProvider.GetDataSource(TableContext.XOTable);

            DataAvail.Data.DataAdapter.IDataAdapter dataAdapter = ControllerProvider.GetDataAdapter(TableContext.XOTable);

            DataAvail.XtraBindings.XtraBindingOperation oper = new DataAvail.XtraBindings.XtraBindingOperation(dataSource, dataAdapter, ControllerProvider.GetObjectCalculator(TableContext.XOTable));

            XtraBinding xtraBinding = null;

            if (TableContext.ShownChildrenRelations.Count() > 0)
            {
                xtraBinding = new DataAvail.XtraBindings.XtraBindingContainer(dataSource, oper);

                foreach (XORelation rel in TableContext.ShownChildrenRelations)
                {
                    DataAvail.XtraBindings.XtraBinding childBinding = CreateXtraBindingSource(rel.ChildTable.CreateTableChildContext(TableContext.Fields.First(p=>p.Name == rel.ParentField.Name)), ControllerProvider, new XtraBindingChildProperties(
                        xtraBinding, rel.ParentTable.Name, rel.ParentField.Name, rel.ChildTable.Name, rel.ChildField.Name));

                    ((XtraBindingContainer)xtraBinding).Children.Add((XtraBindingChild)childBinding);
                }
            }
            else if (ChildProperties != null)
            {
                xtraBinding = new DataAvail.XtraBindings.XtraBindingChild(dataSource, oper, ChildProperties);
            }
            else
            {
                xtraBinding = new XtraBinding(dataSource, oper);
            }

            return xtraBinding;
        }
        internal XtraBinding Clone(DataAvail.XtraBindings.XtraBindingContainer ParentXtraBindingContainer)
        {
            XtraBindingChild xtraBindingChild = new XtraBindingChild(DataSource, xtraBindingOperation, new XtraBindingChildProperties(ParentXtraBindingContainer,
                _xtraBindingChildProperties.parentObjectName, _xtraBindingChildProperties.parentFieldName,
                _xtraBindingChildProperties.childObjectName, _xtraBindingChildProperties.fkFieldName));

            return xtraBindingChild;
        }
        private IEnumerable<object> GetChildrenPKS(XtraBindingChild XtraBinding, IEnumerable<object> ParentPKS)
        {
            XtraBindingUpdateSetEntity entry = _entyties.FirstOrDefault(p => p.xtraBinding == XtraBinding);

            if (entry != null)
            {
                string fk = XtraBinding.ChildProperties.fkFieldName;

                string pk = GetPkFieldName(XtraBinding);

                return entry.StoredItems.Where(p=>ParentPKS.Contains(p.FieldsValues[fk])).Select(p => p.FieldsValues[pk]);
            }
            else
            {
                return null;
            }
        }