public ToEntity GetModel() { ToEntity Result = new ToEntity(); var AllowNames = ToPropertyNames.Where(o => !ExcludeNames.Contains(o)); foreach (var PropertyName in AllowNames) { if (ToCache.IsListProperty(PropertyName)) { continue; } var StingValue = GetRequest(PropertyName); if (null == StingValue) { continue; } try { Type PropertyType = ToCache.PropertyDic[PropertyName].GetType(); SetPropertyValue(Result, PropertyName, StingValue); FoundNamesCount++; } catch (Exception ex) { x.Say(String.Format("设置属性[{0}]的值为[{1}]时候,出现了异常:{2}", PropertyName, StingValue, ex.Message)); } } return(Result); }
public ToEntity CopyData(DataRow source) { if (null == source) { return(null); } ToEntity Result = new ToEntity(); var AllowColumn = source.Table.Columns; var colList = ToPropertyNames.Where(o => AllowColumn.Contains(o)); foreach (string PropertyName in colList) { object NewValue = GetRowValue(source, PropertyName); // continue; try { if (null != NewValue) { SetPropertyValue(Result, PropertyName, NewValue); } } catch (Exception ex) { x.Say(String.Format("设置属性[{0}]的值为[{1}]时候,出现了异常:{2}", PropertyName, NewValue, ex.Message)); } } return(Result); }