public TProperty GetValue <TProperty>(Expression <Func <T, TProperty> > property) { var propertyInfo = property.GetPropertyInfo(); object val; ObjectPropertyValues.TryGetValue(CamelCaseUtil.ToCamelCase(propertyInfo.Name), out val); return((TProperty)val); }
private Dictionary <string, Action <object, object> > ScanForProperties() { // set1 contains simple properties setters that are not related resources var set1 = ObjectPropertyValues .Where(opv => _mapping.PropertySetters.ContainsKey(opv.Key)) .ToDictionary(opv => opv.Key, opv => _mapping.PropertySetters[opv.Key]); // set2 contains simple property setters for 1:1 related resources var set2 = ObjectPropertyValues .Join( _mapping.Relationships.Where(r => !r.IsCollection), opv => opv.Key, r => r.RelationshipName, (opv, r) => new KeyValuePair <string, Action <object, object> >(opv.Key, (Action <object, object>)r.RelatedProperty.SetterDelegate)) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); return(set1.Concat(set2).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)); }