J
John
Hi,
I'm using
DbConnection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation) to
get information from the current data provider. I would like to generate
appropriate parameter names for the current database. This code will be
used with multiple databases (some unknown at this time) and I'm hoping to
come up with a generic way to create parameter names. I've already worked
around the named vs. positional parameter problem. All I need now is to
generate appropriate names when using named parameters. The info returned
by the above statement provides two values that may be useful:
ParameterMarkerFormat and ParameterMarkerPattern. The latter is a regex
pattern. I can see how that can be used to verify a valid name, but not for
generating one, unless there's something about regex I don't know. The
former provides more hope. However, in testing this I found that with SQL
Server this returns "{0}". I would expect it to return "@{0}" (add the
leading "@" character). So I am confused about the usefulness of either of
these and wondering if there is a way to do what I'm doing without having to
write custom code for each database. Along these lines, I'm looking at the
other regex patterns returned like QuotedIdentifierPattern and
CompositeIdentifierSeparatorPattern and wondering if there really is a way
of generating names from all these patterns. I can't believe they'd be
there if they serve no purpose. If anyone can shed a little light on this
I'd really appreciate it.
Thanks,
John
I'm using
DbConnection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation) to
get information from the current data provider. I would like to generate
appropriate parameter names for the current database. This code will be
used with multiple databases (some unknown at this time) and I'm hoping to
come up with a generic way to create parameter names. I've already worked
around the named vs. positional parameter problem. All I need now is to
generate appropriate names when using named parameters. The info returned
by the above statement provides two values that may be useful:
ParameterMarkerFormat and ParameterMarkerPattern. The latter is a regex
pattern. I can see how that can be used to verify a valid name, but not for
generating one, unless there's something about regex I don't know. The
former provides more hope. However, in testing this I found that with SQL
Server this returns "{0}". I would expect it to return "@{0}" (add the
leading "@" character). So I am confused about the usefulness of either of
these and wondering if there is a way to do what I'm doing without having to
write custom code for each database. Along these lines, I'm looking at the
other regex patterns returned like QuotedIdentifierPattern and
CompositeIdentifierSeparatorPattern and wondering if there really is a way
of generating names from all these patterns. I can't believe they'd be
there if they serve no purpose. If anyone can shed a little light on this
I'd really appreciate it.
Thanks,
John