Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Boolean validation
Message
 
À
04/05/2006 17:27:41
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01119418
Message ID:
01119464
Vues:
21
Jeff,

Let me make sure I've got the scenario right...it's a non-nullable bit column in your database, boolean in the Entity object?

>The entity then checks using .GetNonNullableDbValue() and crashes (casting the null to bool). I understand it SHOULD not be null, but it is. In most cases, this would be an error, but during data validation, it should just complain that the value is invalid and notify the user.

GetNonNullableDbValue contains the following code for
public static object GetNonNullableDbValue(object value, string dataType)
{
	return (value == DBNull.Value) ? mmType.GetEmptyDataValue(dataType) : value;
}
This code first checks to see if the value in the DataColumn is == DBNull.value. If it's null, this should evaluate to true, then the first condition in the ternary statement executes:
mmType.GetEmptyDataValue(dataType)
The GetEmptyDataValue() method contains a switch/case statement. For boolean values, the following case should execute:
case "System.Boolean":
{
	emptyValue = false;
	break;
}
This causes the GetEmptyDataValue() method to return false, which is subsequently returned from the GetNonNullableDbValue() method. This means the Entity object property's cast should work fine.

I'm wondering if things are working a bit different for PostGres than for SQL Server. If you can trace through your code and let me know what you're seeing, we can figure this out.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform