public IDbModelPropertyStrategy Parameter <T>(string parameterName, Expression <Func <T, object> > propertySpecifier) { if (typeof(T) != _modelType) { throw new ArgumentException("ERROR_MODEL_TYPE_MISMATCH"); } var parserProvider = _container.Resolve <IDbQueryExpressionMemberNameParserProvider>(); if (parserProvider == null) { throw new InvalidOperationException("DbServiceProvider can't find query expression member name parser provider."); } var propertyName = ExtractPropertyInfo(propertySpecifier); var prop = typeof(T).GetProperty(propertyName); if (prop == null) { throw new ArgumentException("ERROR_PROPERTY_NOT_FOUND"); } IDbModelPropertyStrategy propertyBindingInfo = new DbModelPropertyStrategy(prop); AddOrReplaceParameterBindingInfo(parameterName, propertyBindingInfo); return(propertyBindingInfo); }
public IDbModelPropertyStrategy PropertyExact(PropertyInfo property) { IDbModelPropertyStrategy propertyBindingInfo = new DbModelPropertyStrategy(property); AddOrReplacePropertyBindingInfo(property.Name, propertyBindingInfo); return(propertyBindingInfo); }
private void Initialize() { // create default property binding information. var propQuery = typeof(TModel).GetProperties(); if (!propQuery.Any()) { return; } foreach (var prop in propQuery) { var propBindingInfo = new DbModelPropertyStrategy(prop); AddOrReplacePropertyBindingInfo(prop.Name, propBindingInfo); } }
public virtual IEnumerable <IDbDataParameter> GetDbParameters() { List <IDbDataParameter> parameters = new List <IDbDataParameter>(); if (ModelStrategy == null) { foreach (var column in Columns) { var prop = typeof(TModel).GetProperty(column); var bindingInfo = new DbModelPropertyStrategy(prop); IDbParameterParser parser = new DbParameterParser(bindingInfo); parameters.Add(parser.GetDbParameter()); } } return(parameters); }
public IDbModelPropertyStrategy Property(Expression <Func <TModel, object> > propertySpecifier) { var parserProvider = _container.Resolve <IDbQueryExpressionMemberNameParserProvider>(); if (parserProvider == null) { throw new InvalidOperationException("DbServiceProvider can't find query expression member name parser provider."); } var expressionNode = parserProvider.GetParser(this); string propertyName = expressionNode.Parse(new Dictionary <string, object>(), propertySpecifier.Body); var prop = typeof(TModel).GetProperty(propertyName); if (prop == null) { throw new ArgumentException("ERROR_PROPERTY_NOT_FOUND"); } IDbModelPropertyStrategy propertyBindingInfo = new DbModelPropertyStrategy(prop); AddOrReplacePropertyBindingInfo(prop.Name, propertyBindingInfo); return(propertyBindingInfo); }