public void GetColumnNamesTest() { var mapping = new EntityMapping<Foo>(null); mapping.Add("ID", f => f.ID, (f, n) => f.ID = n, true); mapping.Add("Name", f => f.Name, (f, n) => f.Name = n, false); Assert.Equal("Name", mapping.GetColumnNames().Skip(1).Single()); }
/// <summary> /// Updates the mapping depending on user selection. /// </summary> /// <param name="mapping">The mapping to update.</param> public void UpdateMapping(EntityMapping mapping) { string value = AttributeDropDownList.SelectedValue; if (!String.IsNullOrEmpty(value)) { string[] tokens = value.Split('-'); if (tokens[0] == "Attribute" || tokens[0] == "RestrictedAttribute") { string attributeName = tokens[1]; EntityAttributeModel attributeModel = UserProfileModel.GetAttributeModel(attributeName); if (attributeModel != null) { mapping.Add(attributeModel, FieldInfo, FieldScope); } } } }
/// <summary> /// Creates a mapping of CMS contact (or account) fields and Data.com contact (or company) attributes from the current form state, and returns it. /// </summary> /// <returns>A mapping of CMS contact (or account) fields and Data.com contact (or company) attributes.</returns> private EntityMapping CreateEntityMappingFromForm() { EntityMapping mapping = new EntityMapping(); foreach (FormFieldInfo fieldInfo in mContext.FormInfo.GetFields(true, false)) { CMSDropDownList dropDownList = mAttributeNamesDropDownLists[fieldInfo.Name]; if (dropDownList.SelectedIndex != 0) { EntityAttributeInfo attributeInfo = mContext.EntityInfo.GetAttributeInfo(dropDownList.SelectedValue); if (attributeInfo != null) { mapping.Add(attributeInfo, fieldInfo); } } } return(mapping); }
/// <summary> /// Creates a mapping of CMS contact (or account) fields and Data.com contact (or company) attributes from the current form state, and returns it. /// </summary> /// <returns>A mapping of CMS contact (or account) fields and Data.com contact (or company) attributes.</returns> private EntityMapping CreateEntityMappingFromForm() { EntityMapping mapping = new EntityMapping(); foreach (FormFieldInfo fieldInfo in mContext.FormInfo.GetFields(true, false)) { DropDownList dropDownList = mAttributeNamesDropDownLists[fieldInfo.Name]; if (dropDownList.SelectedIndex != 0) { EntityAttributeInfo attributeInfo = mContext.EntityInfo.GetAttributeInfo(dropDownList.SelectedValue); if (attributeInfo != null) { mapping.Add(attributeInfo, fieldInfo); } } } return mapping; }