public static PocoData ForObjectStatic(object o, string primaryKeyName, bool autoIncrement, Func<Type, PocoData> fallback)
{
var t = o.GetType();
#if !NET35
if (t == typeof (System.Dynamic.ExpandoObject) || t == typeof (PocoExpando))
{
var pd = new PocoData
{
TableInfo = new TableInfo
{
PrimaryKey = primaryKeyName,
AutoIncrement = autoIncrement
},
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase)
};
foreach (var col in ((IDictionary<string, object>)o))
{
pd.Columns.Add(col.Key, new ExpandoColumn
{
ColumnName = col.Key,
MemberInfoData = new MemberInfoData(col.Key, col.Value.GetTheType() ?? typeof(object), typeof(object)),
});
}
if (!pd.Columns.ContainsKey(primaryKeyName))
{
pd.Columns.Add(primaryKeyName, new ExpandoColumn { ColumnName = primaryKeyName, ColumnType = typeof(object) });
}
return pd;
}
else
#endif
return fallback(t);
}