none
Problem with EF and VB: can't set a property to "" RRS feed

  • Question

  • Using EF v 4.1.  

    Of course, "" is not null, and it should be possible to assign "" to a property.  I have a property N_ADD_ID that corresponds to a non-nullable field.  But the EF-generated "setter" for property N_ADD_ID does this:

     

            Set
                If (_N_ADD_ID <> Value) Then
                    OnN_ADD_IDChanging(value)
                    ReportPropertyChanging("N_ADD_ID")
                    _N_ADD_ID = StructuralObject.SetValidValue(Value, False)
                    ReportPropertyChanged("N_ADD_ID")
                    OnN_ADD_IDChanged()
                End If
            End Set
    

     


    The problem is: when _N_ADD_ID is Nothing and Value is "", "If (_N_ADD_ID <> Value)" returns False, so _N_ADD_ID can never get changed from Nothing to "".

    I think the generated code should be checking "If not (value.Equals(_N_ADD_ID))". That would return True and things would work as expected.

     


    • Edited by Kbd Guy Wednesday, September 21, 2011 5:38 PM
    Wednesday, September 21, 2011 5:35 PM

All replies