I am confused why this code is in the EntityGridView. Can anyone explain why this is necessary? The result is that it adds a new entity to the list when I call my custom proc that returns no records. I don't see this with methods that return a TList, but for whatever reason, it happens with a VList. I can't think of any scenario where I would want to add a blank entity to my list after returning no results. Can anyone shed some light on this?
/// <summary>
/// Retrieves data from the underlying data storage by calling the method that is identified by the
/// SelectMethod property with the parameters in the SelectParameters collection.
/// </summary>
/// <remarks>
/// Occurs when a Select operation has completed.
/// </remarks>
void dsc_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.AffectedRows == 0)
{
// check if gridview bound to typed object data source
if (sender is Web.Data.IListDataSource)
{
// get the types of the generic type arguments
Type[] typeArguments = ((DataSourceControl)sender).GetType().BaseType.GetGenericArguments();
// create empty business object
object entity = EntityUtil.GetNewEntity(EntityUtil.GetType(typeArguments[0].FullName));
// add empty object to the collection -- I COMMENTED OUT THE NEXT LINE
//EntityUtil.Add(e.ReturnValue as System.Collections.IList, entity);
}
}
RecordsCount = e.AffectedRows;
}