public void DoRemove(TEntity childEntity, bool referenceOnly = true)
        {
            string key = EntityTableHelper <TEntity> .RetriveKey(childEntity).ToString();

            var proxyInfo = childEntity as IEntityProxyInfo;

            if (foreignKeyMap == null)
            {
                foreignKeyMap = new Dictionary <Guid, object>();
            }
            foreignKeyMap.Remove(proxyInfo.Proxy.Row.InternalId);
            if (!referenceOnly)
            {
                var foreignTableProxy = new EntityTableProxy <TEntity>(proxyInfo.Proxy.Row.Table, this.SourceProvider);
                foreignTableProxy.Remove(childEntity);
            }
            //int idx = this.EntityRelation.Keys.IndexOf(key);
            if (this.EntityRelation.Keys.Remove(key))
            {
                //  UpdateContent();
                //NotifyCollectionChangedAction.Remove會當,原因不明
                //NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, childEntity, idx);
                // NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
                //  OnCollectionChanged(e);
                //FireResetNotifyCollection();

                UpdateContent();
            }
        }
        public bool TryGetForeignTable(out EntityTableProxy <TEntity> foreignTableProxy)
        {
            foreignTableProxy = null;
            EntityTable foreignTable;

            if (TryGetForeignTable(out foreignTable))
            {
                foreignTableProxy = new EntityTableProxy <TEntity>(foreignTable, this.SourceProvider);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        static public EntityTable GenEntitySchema(EntityTable srcTbl)
        {
            var schemaTable = CreateEntitySchema();

            schemaTable.Namespace = srcTbl.Namespace;
            schemaTable.TableName = srcTbl.TableName;
            var schemaTableProxy = new EntityTableProxy <IEntitySchema>(schemaTable);

            foreach (var column in srcTbl.Columns)
            {
                var colDef = schemaTableProxy.Append();
                column.CopyTo(colDef);
                //attris.Status = OPStatus.Steady;//在此代表此column為舊有非新增的
            }
            return(schemaTable);
        }
Exemplo n.º 4
0
        static public EntityTable CreateEntitySchema(bool genDefaultKey = false)
        {
            var schema = EntityTableHelper <IEntitySchema> .CreateDataTable();

            schema.Columns["DataType"].DefaultValue  = typeof(string).FullName;
            schema.Columns["FieldType"].DefaultValue = EntityFieldType.Var.ToString();
            if (genDefaultKey == true)
            {
                var tblProxy = new EntityTableProxy <IEntitySchema>(schema);
                var colDef   = tblProxy.Append();
                colDef.Unique     = true;
                colDef.KeyGen     = "id_{0}";
                colDef.ColumnName = "Id";
                schema.TableName  = "";
            }
            return(schema);
        }
        static public bool TryGetTable <TEntity>(this IEntityTableSource it, out EntityTableProxy <TEntity> tableProxy, string ns, string tableName, params string[] keys)
        {
            var selectCond = new EntityRelation(ns, tableName, keys);

            return(it.TryGetTable(selectCond, out tableProxy));
        }