hherzl / CatFactory

CatFactory Scaffolding Engine
MIT License
55 stars 11 forks source link

Fix definition for ExtendedProperties in ImportBag property in Column class #18

Open hherzl opened 1 year ago

hherzl commented 1 year ago

In order to use AddColumnForTables extension method, there is a hack:

dynamic importBag = new ExpandoObject();

importBag.ExtendedProperties = new List<ExtendedProperty>();

db.AddColumnForTables(new Column { Name = "Active", Type = "bit", ImportBag = importBag });
db.AddColumnForTables(new Column { Name = "CreationUser", Type = "nvarchar", Length = 50, ImportBag = importBag });
db.AddColumnForTables(new Column { Name = "CreationDateTime", Type = "datetime", ImportBag = importBag });
db.AddColumnForTables(new Column { Name = "LastUpdateUser", Type = "nvarchar", Length = 50, Nullable = true, ImportBag = importBag });
db.AddColumnForTables(new Column { Name = "LastUpdateDateTime", Type = "datetime", Nullable = true, ImportBag = importBag });
db.AddColumnForTables(new Column { Name = "Version", Type = "rowversion", Nullable = true, ImportBag = importBag });

This is a suggested fix for ImportBag property definition in Column class:

[XmlIgnore]
public dynamic ImportBag
{
    get
    {
        if (m_importBag == null)
        {
            m_importBag = new ExpandoObject();
            m_importBag.ExtendedProperties = new List<ExtendedProperty>();
        }

        return m_importBag;
    }
    set
    {
        m_importBag = value;
    }
}