views:

461

answers:

1

I have a datagridview that is bound to a bindingsource which is in turn bound to the an EDM object. I'm importing objects from a CSV file and wish to add these objects to the EDM context and have the new items show up in my datagridview. However, I do not want the new objects committed to the database until the user indicates the data should be saved.

When I do the following, everything works ok except the new objects do not show up in the datagridview until I call myContext.SaveChanges() (This doesn't allow to see the objects that were just imported before saving):

while (objects in file)
{
   // extract object from file

   // verify new object

   myContext.AddToxxx(newObject)
}

I've also tried this which allows the objects to show up in the datagridview ok, but an exception is thrown when I call myContext.SaveChanges()

while (objects in file)
{
   // extract object from file

   // verify new object

   bindingSource.Add(newObject);
}

What am I missing?

A: 

no one cares here ye? I'm interesed in creating Entity programmatically. ex: I've Entities on which application is working. I want to implement functionality in which user can add additional Tables to database. This will require that EDM has this new tables as Entities. how can this be done?

gperc