/// <summary> /// Inserts the specified name/value pairs into the /// relationship defined by the specified member. /// </summary> /// <param name="member">The relationship member.</param> /// <param name="links">A collection of business objects.</param> /// <param name="values">A collection of name/value pairs to insert.</param> /// <param name="initEntityKey">A value indicating whether or not to initialize the /// business object's unique identifier property before executing the insert operation.</param> private void Insert(EntityRelationshipMember member, IList links, IDictionary values, bool initEntityKey) { if (member != null && member.HasDataSource) { member.GetLinkedDataSource().Insert(values); } else { Object link = EntityUtil.GetNewEntity(member.EntityType); EntityUtil.SetEntityValues(link, values); if (initEntityKey) { EntityUtil.SetEntityKeyValue(link, member.EntityKeyName); } EntityUtil.Add(links, link); } }
/// <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 && ShowGridOnEmptyData) { // 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 EntityUtil.Add(e.ReturnValue as System.Collections.IList, entity); } } RecordsCount = e.AffectedRows; }