views:

22

answers:

1

Hello I'am using MVC 2 with Entity Framework (the newest that came with VS2010 RC) and have the following problem:

Due to compatibility reasons the example User entity in the database contains field called "Disabled" which is the type of int with values 0 or 1 (to be mapped to bool). In my edmx mappings this field is called 'disabled' and it's getter and setter are internal. Then an additional partial class exposes this field as bool property 'Disabled' for in-code operations:

public partial class User
{
    public virtual bool Disabled
    {
        get { return Convert.ToBoolean(this.disabled); }
        set { this.disabled = Convert.ToInt16(value); }
    }
}

It works fine until I need to update the user by typical edit form then TryUpdateModel fails with the message:

The value 'false' is not valid for Disabled.

I don't know why MVC doesn't map this correctly. Any ideas? Thanks

+1  A: 

I suspect that the whole thing about disabled being a different type from Disabled is a red herring. Is it just that "false" is a string that needs parsing?

pdr
actually, it works perfectly - found bug in another code. Thank you for your help.
twk