public static void UpdateMetaFields(this EntityObject entity, ExtendedBaseModel model, List <string> ignoreFields) { var metaClass = DataContext.Current.MetaModel.MetaClasses.Cast <MetaClass>() .FirstOrDefault(x => x.Name.Equals(entity.MetaClassName)); if (metaClass == null) { return; } foreach (var property in entity.Properties.Where(x => !ignoreFields.Contains(x.Name))) { var metaField = metaClass.Fields.Cast <MetaField>().FirstOrDefault(x => x.Name.Equals(property.Name)); if (metaField == null) { continue; } var modelProperty = model.MetaFields.FirstOrDefault(x => x.Name.Equals(property.Name)); if (modelProperty?.Values == null) { continue; } var value = BusinessFoundationFactory.GetMetaFieldValue(metaField, modelProperty.Values); if (value == null) { continue; } property.Value = value; } }
public static List <ExtendedMetaFieldProperty> GetMetaFields(this EntityObject entity, List <string> ignoreFields) { var metaFields = new List <ExtendedMetaFieldProperty>(); var metaClass = DataContext.Current.MetaModel.MetaClasses.Cast <MetaClass>() .FirstOrDefault(x => x.Name.Equals(entity.MetaClassName)); if (metaClass == null) { return(metaFields); } foreach (var property in entity.Properties.Where(x => !ignoreFields.Contains(x.Name))) { var metaField = metaClass.Fields.Cast <MetaField>().FirstOrDefault(x => x.Name.Equals(property.Name)); if (metaField == null) { continue; } var value = BusinessFoundationFactory.GetMetaFieldSerializationValue(metaField, property.Value); if (value == null) { continue; } metaFields.Add(new ExtendedMetaFieldProperty { Name = property.Name, Type = metaField.TypeName, Values = new List <string> { value } }); } return(metaFields); }