IEditableCollectionView.AddNew() Throwing ArgumentNullException
Posted
by Eugarps
on Stack Overflow
See other posts from Stack Overflow
or by Eugarps
Published on 2010-06-07T20:57:46Z
Indexed on
2010/06/07
21:02 UTC
Read the original article
Hit count: 539
In the context of Silverlight RIA using DomainContext and, the code as follows:
private void AddProductButton_Click(object sender, RoutedEventArgs e)
{
var target = (Web.LocatorProduct)((IEditableCollectionView)ProductSource.DataView).AddNew();
target.Locator = LocatorID;
target.Product = NewProduct.Text.ToUpper();
((IEditableCollectionView)ProductSource.DataView).CommitNew();
}
Is throwing ArgumentNullException in AddNew(), CreateIdentity() further up on the stack (a generated method) due to product being null. Product and LocatorID are, in combination, the primary key.
I'm guessing that EF is not allowing me to generate a new item without meeting database contraints? How does this make sense if I need to obtain a primary key from the user?
I have control over all tiers of the application, so suggestions on database design if needed are also welcomed.
© Stack Overflow or respective owner