I have an SQL Server stored procedure that ressembles this:
CREATE PROCEDURE [jp].[GetFoo]
@Guid UNIQUEIDENTIFIER
AS
SELECT
CONVERT(BIT, (CASE WHEN [dbo].[GetBar](T.Col2) = 3 THEN 1 ELSE 0 END)) IsGetBarCol2EqualToThree
FROM
[dbo].[MyTable] T
WHERE
T.Col1 = @Guid
When I do Function Import / Get Column Information in EF, the inferred type of the column IsGetBarCol2EqualToThree is Nullable<bool>
. But there is no way this field is going to be null, so I'd like it to be just bool
. Is there a way to do this that would be persistent upon updating (ie that does not rely on modifying any generated code)?
The SQL Server version is 2005, I'm using Visual Studio 2010SP1 with EF 4, project is compiled against .net 4.0.
Make this modification: isnull([dbo].[GetBar](T.Col2), 0)
You can create complex type and then modify the Nullable property of the generated field. Can be useful if you don't want to change your sp.
step by step:
Alternatively you can open edmx as xml and find the same property.
<ComplexType Name="...">
<Property Type="Int32" Name="..." Nullable="true" />
ps: I tested it in VS2012, EF 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With