Guido Neele Guido Neele - 2 months ago 25
C# Question

C# Entity Framework ANSI NULL OFF

We've created a WPF application that uses entity framework to connect with a database. In the database there are several stored procedures that I would like to execute. I've imported the stored procedure as functions in EF and everything seems OK, except it isn't. If I execute the stored procedure nothing happens in the database. If I execute the stored procedure in the SQL Server Management Studio, with the same data, then some rows are being processed as expected. That wasn't always the case. It only started to work in SQL Server Management Studio when I disabled CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER, ANSI_NULL_DFLT_ON, ANSI_PADDING, ANSI_WARNINGS and ANSI_NULLS. How can I also make it work in the application itself?

Guido

Answer

Solved this problem by using:

Context.ExecuteStoreCommand(@"
   SET CONCAT_NULL_YIELDS_NULL OFF
   SET QUOTED_IDENTIFIER OFF
   SET ANSI_NULL_DFLT_ON OFF
   SET ANSI_PADDING OFF
   SET ANSI_WARNINGS OFF
   SET ANSI_NULLS OFF

   exec sp params
")

Thanks Guido

Comments