Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
NewEntity creates duplicate entities
Versions des environnements
In version 2.4 using the NewEntity function seems to create 2 Entities. I looked at the source code:
public virtual EntityType NewEntity(object defaultValues)
{
DataRow Row = this.NewRow(defaultValues);
And then in NewRow:
public override DataRow NewRow(System.Data.DataSet ds, string tableName, object defaultValues)
{
DataRow Row = base.NewRow(ds, tableName, defaultValues);
if (tableName == this.TableName)
{
if (EntityList != null)
{
EntityType EntityObject = this.CreateEntityObject();
EntityObject.SetDataRow(Row);
this.EntityList.Add(EntityObject);
}
}
return Row;
}
Which creates an entity object and adds it to the list. But then continued in NewEntity:
public virtual EntityType NewEntity(object defaultValues)
{
DataRow Row = this.NewRow(defaultValues);
EntityType EntityObject = this.CreateEntityObject();
EntityObject.SetDataRow(Row);
if (EntityList != null)
{
this.EntityList.Add(EntityObject);
}
return EntityObject;
Am I correct that there is a bug, or am I doing something wrong?
Thanks!
Danny
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement