1

I am adding scalar parameters in my SQLquery, but whenever the query executes I am getting an exception for the follwoing piece of code:

IEnumerable<ICRDocumentComplete> results = saturnContext
                .Set<ICRDocumentComplete>()
                .SqlQuery(query,
                    new SqlParameter("@StartDate", startDate),
                    new SqlParameter("@EndDate", endDate.AddDays(1)),
                    new SqlParameter("@SubmissionId", submissionId));

I have my query saved inside the query variable. I am getting a null reference, but I am assuming it is just because I didn't add the scalar variables correctly. Can someone shed some light on this matter?

Hussam Ahmed
  • 131
  • 11
  • 2
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – madreflection Oct 23 '20 at 16:16

1 Answers1

0

make sure that saturnContext, query, endDate is not null at the time of execution.

Derviş Kayımbaşıoğlu
  • 24,022
  • 2
  • 42
  • 59