I would like to set a do something like this dataSet1.EnforceConstraints = false;
using the Dapper.Net ORM and Entity Framework.
I created the models in VS2010 where a property:
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
public global::System.String ethnicname
{
get
{
return _ethnicname;
}
set
{
OnethnicnameChanging(value);
ReportPropertyChanging("ethnicname");
_ethnicname = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("ethnicname");
OnethnicnameChanged();
}
}
... when value
is null
, I get a constraint exception at StructuralObject.SetValidValue...
. How and where do I turn this off?
My data call looks like this:
public DAL.Models.PROFILE GetProfile(int profileID)
{
using (IDbConnection connection = OpenConnection("MyDBConnectionString"))
{
try
{
var profiles = connection.Query<DAL.Models.PROFILE>("SELECT * FROM PROFILES WHERE ID=@ID", new { ID = profileID }); // IEnumerable
var profile = profiles.First<DAL.Models.PROFILE>();
return profile;
}
catch (Exception ex)
{
ErrorLogging.Instance.Fatal(ex);
return null;
}
}
}