public static TEntity MapSelectorWithVales <TEntity>(Dictionary <string, object> valuePairs) where TEntity : class, new() { TEntity instance = Activator.CreateInstance <TEntity>(); foreach (PropertyInfo property in typeof(TEntity).GetProperties()) { PropertyInfo propertyInfo = property; KeyValuePair <string, object> keyValuePair = valuePairs.Where(p => p.Key.ToLower() == propertyInfo.Name.ToLower()).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(keyValuePair.Key)) { BuildUntypedSetter <TEntity>(propertyInfo)(instance, keyValuePair.Value); } } return(instance); }
public static TEntity MapSelectorWithVales <TEntity>(Dictionary <string, object> valuePairs) where TEntity : class, new() { var entity = new TEntity(); foreach (var property in typeof(TEntity).GetProperties()) { var propertyInfo = property; var keyValuePair = valuePairs.Where(p => p.Key.ToLower() == propertyInfo.Name.ToLower()) .FirstOrDefault(); if (!string.IsNullOrWhiteSpace(keyValuePair.Key)) { BuildUntypedSetter <TEntity>(propertyInfo)(entity, keyValuePair.Value); } } return(entity); }