Thanks for raising this. I believe it is fixed in the upcoming NHibernate release. Have a look at this bug report:
https://nhibernate.jira.com/browse/NH-2893 If you can't wait for an official release, you can download ( https://github.com/nhibernate/nhibernate-core) and compile the source code. Regards Julian On 27 December 2011 03:34, Mike Charalambous <[email protected] > wrote: > Hi > > I have recently written a NHibernate driver for the Sybase Advantage > Database Server (ADS), and have across a bug in the function > RemoveUnusedCommandParameters when running queries with parameters in > them. This bug means that all parameters are removed by > RemoveUnusedCommandParameters instead of just the ones which are > unused. Please see the bottom of my post for the driver code. > > The heart of the issue is that ADS requires a prefix to be used when > referring to parameters in SQL, but not when the parameter is in the > parameter collection. The RemoveUnusedCommandParameters function does > not take into account that the parameter name can have a prefix in the > SQL and not in the parameter collection and so removes all parameters > from the command object. > > I think the fix for this issue is straightforward and as far as I can > tell will not cause any issues with existing drivers. The code: > > .Select(p => p.ParameterName) > > should be changed to: > > .Select(p => FormatNameForSql(p.ParameterName)) > > > I have created a unit test for this issue but it requires binaries for > the Advantage Database Server. Is this okay? > > Thanks > > Mike Charalambous > > public class SybaseAdsClientDriver : > NHibernate.Driver.ReflectionBasedDriver > { > public SybaseAdsClientDriver() > : base("Advantage.Data.Provider", > "Advantage.Data.Provider.AdsConnection", > "Advantage.Data.Provider.AdsCommand") > { > } > > public override bool UseNamedPrefixInSql > { get { return true; } } > > public override bool UseNamedPrefixInParameter > { get { return false; } } > > public override string NamedPrefix > { get { return ":"; } } > } > >
