views:

25

answers:

1

I have a SQL Server 2008 database. I have a bunch of fields in TableA that are just strings that corresponds to booleans. So every value is either true or false. The edmx I generated using Entity Framework 4.0 has them as strings. This is technically correct but I would like to have them mapped as Booleans instead. Is this possible? If so how can I accomplish this?

Thanks much!

+1  A: 

You could create a partial class alongside the generated one and add the bool property there with code to go back and forth from bool to string version. You could also mark the generated property as protected or internal to hide it from the rest of your code.

It's not ideal since the bool property cannot appear in query expressions unless you first force the query to happen using, for example, .ToList().

Your best bet would be to fix the database.

Hightechrider
Changed it to the "bit" datatype in the database and now it reflects as a boolean in the database. Didn't even realize I could use that. Thanks much
Tom