CatFactory icon indicating copy to clipboard operation
CatFactory copied to clipboard

Fix definition for ExtendedProperties in ImportBag property in Column class

Open hherzl opened this issue 2 years ago • 0 comments

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;
	}
}

hherzl avatar Jan 04 '23 01:01 hherzl