I'm building an application and I have an EF4 EDM. I have imported a number of stored procedures as function imports into the model. Most of these functions do not return any return value.
I'm getting the following null reference exception when I call one of these function import methods:
System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.EntityClient.EntityDataReader.Close() at System.Data.EntityClient.EntityDataReader.Dispose(Boolean disposing) at System.Data.Common.DbDataReader.Dispose() at System.Data.EntityClient.EntityCommand.ExecuteScalar[T_Result](Func`2 resultSelector) at System.Data.EntityClient.EntityCommand.ExecuteNonQuery() at System.Data.Objects.ObjectContext.ExecuteFunction(String functionName, ObjectParameter parameters) at LPRCore.CarSystem.CarSystemEntities.UpsertList(Nullable`1 listId, String listName, Nullable`1 listTypeId, Nullable`1 domainId, String salt, Nullable`1 lastUpdated, Nullable`1 whiteListAlarmClassId, Nullable`1 subscriber, Nullable`1 instanceId) in D:\ElsagTFS\EOC4\Client\LPRCore Plugin CarSystem\CarSystemModel.Designer.cs:line 2050 at LPRCore.CarSystem.HotListDataAccessor.SaveHotList(CarSystemEntities context, Nullable`1 subscriberId, Nullable`1 instanceId, HotList data) in D:\ElsagTFS\EOC4\Client\LPRCore Plugin CarSystem\HotListDataAccessor.cs:line 268
How do I correct this, or is it a problem in the provider?
I've found that the null reference exception does not occur if I modify the stored procedure so it returns a value by adding "SELECT 1;" to the end of the stored procedure. This is even though the Function Import's properties indicate that the return type is None.
We are actually in the process of evaluating SA and I have a contact inside Sybase. I've also reported this to him. He's been able to reproduce the issue and has sent it to the internal team responsible for this. So it is probably going to be fixed and released soon.
answered 08 Sep '12, 11:10