I have to execute a stored procedure in SQL that returns a few rows, but I can never seem to capture the results in nHibernate. I've asked my whole Dev team to no avail. Here's my code:
var results = this.Session.CreateSQLQuery("EXEC qa.AdjustDates @VpGuarantorId =:VpGuarantorId, @DatePart =:DatePart, @Adjustment =:Adjustment")
.AddScalar("IssueLevel", NHibernateUtil.String)
.AddScalar("IssueMessage", NHibernateUtil.String)
.SetParameter("VpGuarantorId", guarantorId)
.SetParameter("DatePart", datePart)
.SetParameter("Adjustment", adjustment)
.SetResultTransformer(new AliasToBeanResultTransformer(typeof (IssueResult)))
.List<IssueResult>()
.ToList();
Here's the class:
public class IssueResult
{
public virtual string IssueLevel { get; set; }
public virtual string IssueMessage { get; set; }
}
(PS - SQL Profiler shows our app is correctly calling the proc and passing the right parameters)
Well, this was a case of having the same SPROC in two databases and not knowing it: code was hitting one database and I was testing my query in a different one.
Sorry for the stupid question and thank you all for the great answers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.