Unable to find changed User Defined Columns at runtime with IdeaBlade

54 Views Asked by At

I was following the IdeaBlade instructional unit for User Defined Columns, I have created the following method:

    public static IEnumerable<DataColumn> GetUnknownColumns(PersistenceManager pManager, Type pType)
    {
        PropertyDescriptorList.Reset(pType);
        var definedDescriptors = PropertyDescriptorList.Get(pType);
        pManager.Clear();
        pManager.InitializeSchema(pType);
        EntityTable uddTable = pManager.GetTable(pType);
        foreach (DataColumn col in uddTable.Columns)
        {
            PropertyDescriptor prop = definedDescriptors.Find(col.ColumnName);

            if (prop == null)
                yield return col;
        }
    }

Note: pType is assumed to be an IdeaBlade.Persistence.Entity. This code works great, except if I make changes to the entity/table that pType points to during runtime, this code will no pick up the new columns. Furthermore, if I remove a column it will still appear in uddTable.Columns. What am I doing incorrect?

EDIT Fixed a typo (manager -> pManager). I have also figured out the issue, I was modifying the table pType points to through sql and not through the PM, which I believe to be the cause of the issue. I fixed it by adding EntityTypeInfo.GetPrototypeTable(pType).IsSchemaInitialized = false; before the InitializeSchema call

0

There are 0 best solutions below