General information
Category:
The Mere Mortals .NET Framework
Title:
NewEntity creates duplicate entities
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only