http://www.strangelights.com/blog/archive/2004/06/10/148.aspx
Looks like you have to call .NextResult() on a reader before a SQL RAISEERROR will throw an exception in the .NET client code.
This issue manifests itself in the Microsoft web service software factory in the Repository.cs class file, for the implementations for Find and FindOne. The corrected code is posted below for reference.
public List<TDomainObject> Find<TIdentity>(
ISelectionFactory< TIdentity > selectionFactory,
IDomainObjectFactory<TDomainObject> domainObjectFactory,
TIdentity identity)
{
List<TDomainObject> results = new List<TDomainObject>();
using (DbCommand command = selectionFactory.ConstructSelectCommand(db, identity))
{
using (IDataReader rdr = db.ExecuteReader(command))
{
do
{
while (rdr.Read())
{
results.Add(domainObjectFactory.Construct(rdr));
}
} while (rdr.NextResult());
}
}
return results;
}
public TDomainObject FindOne<TIdentity>(
ISelectionFactory<TIdentity> selectionFactory,
IDomainObjectFactory<TDomainObject> domainObjectFactory,
TIdentity identity)
{
TDomainObject result = default(TDomainObject);
using (DbCommand command = selectionFactory.ConstructSelectCommand(db, identity))
{
using (IDataReader rdr = db.ExecuteReader(command))
{
do
{
if (rdr.Read())
{
result = domainObjectFactory.Construct(rdr);
}
} while (rdr.NextResult());
}
}
return result;
}