views:

63

answers:

1

Hi

I have a stored procedure that declares a input parameter

@BatchNumber uniqueidentifier 

This field in the table is set to not allow nullables.

When I drag in the stored procedure and it hooks everything up it says the parameter is nullable.

I don't understand why. Is this normal for it to think that the parameters are nullable?

A: 

All variables in Sql are nullable. There is no way to make a non-nullable variable in sql.

 --yup, it's nullable.  even starts initialized to null.
DECLARE @MyVar int

If you change the parameter type in the designer, that should be fine.

The mapping code can have a non-nullable and hand it to the database and the database will call it a nullable and there is no problem. This happens with every non-nullable in your queries already... such as non-nullable integer IDs in Where clauses.

If you can't set the type as desired in the designer.. here's what to do. Take the generated code for the method and copy it out of the designer.cs file into a new partial class definition. Set the type by hand in the attributes of the method. Remove the stored proc from the designer (at this point, the stored proc is a manual addition). We had to use this style of fix to allow OUTPUT parameters to work.

David B
Ah so make a partial class with it overriding this nullable type. That way even if the DBML is recreated it won't effect it.
chobo2