public ObjectBinder <T> CreateObjectBinder <T>() { var objectBinderPropertyList = new List <ObjectBinderProperty <T> >(DataReader.FieldCount); for (int i = 0; i < DataReader.FieldCount; ++i) { string columnName = DataReader.GetName(i); string propertyName = bindStrategy.ToPropertyName(columnName); var propertyInfo = LeettleDbUtil.FindProperty(typeof(T), propertyName); if (propertyInfo != null) { objectBinderPropertyList.Add(new ObjectBinderProperty <T>(i, propertyInfo)); } } return(new ObjectBinder <T>(objectBinderPropertyList.ToArray())); }
public DbCommandWrapper BindParam(object paramObject) { Assert.NotNull(paramObject, "paramObject must not be null"); Type paramType = paramObject.GetType(); var matches = new Regex("(" + BindStrategy.ParameterMarker + "[A-Za-z0-9_$#]*)").Matches(sql); foreach (var match in matches) { string parameterName = match.ToString().Substring(1); string propertyName = BindStrategy.ToPropertyName(parameterName); var property = LeettleDbUtil.FindProperty(paramType, propertyName); if (property != null) { object paramValue = property.GetValue(paramObject, null); AddParam(parameterName, paramValue); } } return(this); }