/// <summary> /// Creates an instance of this class /// </summary> /// <param name="spatialDbUtility">The spatial db utility class</param> /// <param name="connectionString">The connection string</param> /// <param name="schema">The name of the schema</param> /// <param name="table">The table name</param> /// <param name="oidColumn">The object ID column</param> /// <param name="geometryColumn">The geometry column</param> protected SpatialDbProvider(SpatialDbUtility spatialDbUtility, string connectionString, string schema, string table, string oidColumn, string geometryColumn) : base(0) { ConnectionID = connectionString; _dbUtility = spatialDbUtility; _schema = schema; _table = table; _oidColumn = new SharpMapFeatureColumn { Column = oidColumn }; _geometryColumn = new SharpMapFeatureColumn { Column = geometryColumn }; // Additional columns _featureColumns = new SharpMapFeatureColumns(this, spatialDbUtility); _featureColumns.FeatureColumnsChanged += OnFeatureColumnsChanged; }
/// <summary> /// Decorates a constraint with parameters /// </summary> /// <param name="command">The command object to add the parameters to.</param> /// <param name="entity">The entity</param> /// <param name="constraint"></param> /// <param name="parameters"></param> /// <returns></returns> public string DecorateEntityConstraintWithParameter(DbCommand command, SharpMapFeatureColumn entity, string constraint, params object[] parameters) { var sb = new StringBuilder(); var pc = command.Parameters; var pNr = pc.Count; foreach (var o in parameters) { var p = command.CreateParameter(); p.DbType = entity.DbType; p.ParameterName = string.Format(ParameterDecoratorFormat, pNr++); p.Value = o; pc.Add(p); if (sb.Length > 0) { sb.Append(", "); } sb.AppendFormat(p.ParameterName); } var formattedConstraint = string.Format(constraint, sb); return(string.Format("{0} {1}", DecorateEntity(entity.Column), formattedConstraint)); }
/// <summary> /// Decorates a constraint with parameters /// </summary> /// <param name="command">The command object to add the parameters to.</param> /// <param name="entity">The entity</param> /// <param name="constraint"></param> /// <param name="parameters"></param> /// <returns></returns> public string DecorateEntityConstraintWithParameter(DbCommand command, SharpMapFeatureColumn entity, string constraint, params object[] parameters) { var sb = new StringBuilder(); var pc = command.Parameters; var pNr = pc.Count; foreach (var o in parameters) { var p = command.CreateParameter(); p.DbType = entity.DbType; p.ParameterName = string.Format(ParameterDecoratorFormat, pNr++); p.Value = o; pc.Add(p); if (sb.Length > 0) sb.Append(", "); sb.AppendFormat(p.ParameterName); } var formattedConstraint = string.Format(constraint, sb); return string.Format("{0} {1}", DecorateEntity(entity.Column), formattedConstraint); }