I am using the db scaffolding and EF defaults to using Hashset.
This causes a casting error on the RunTimeTableAdapterProvider.cs (line 38). My work-around is to remove the casting altogether.
` public ITableDataAdapter CreateCollectionTableDataAdapter(object selectedItem, PropertyInfo propertyInfo)
{
var propertyType = propertyInfo.PropertyType.GenericTypeArguments[0];
var propertyValueGetter = propertyValueAccessorCache.GetPropertyAccesor(selectedItem.GetType());
var collectionValue = propertyValueGetter.GetValue(selectedItem, propertyInfo.Name); // EF is defaulting to HashSet and conversion to ICollection causes an exception - removed the "as ICollection" and now it works
var dataAdapterType = typeof(CollectionTableDataAdapter<>).MakeGenericType(propertyType);
var dataAdapter = Activator.CreateInstance(dataAdapterType,
new object[] { collectionValue }) as ITableDataAdapter;
return dataAdapter;
}`
I am using the db scaffolding and EF defaults to using Hashset.
This causes a casting error on the RunTimeTableAdapterProvider.cs (line 38). My work-around is to remove the casting altogether. ` public ITableDataAdapter CreateCollectionTableDataAdapter(object selectedItem, PropertyInfo propertyInfo) { var propertyType = propertyInfo.PropertyType.GenericTypeArguments[0]; var propertyValueGetter = propertyValueAccessorCache.GetPropertyAccesor(selectedItem.GetType()); var collectionValue = propertyValueGetter.GetValue(selectedItem, propertyInfo.Name); // EF is defaulting to HashSet and conversion to ICollection causes an exception - removed the "as ICollection" and now it works