After upgrading my project from 12.2 to 13.2, and doing some required changes for the upgrade ( mostly related to Validator.RuleSet.Validate to include the object space).
I got the following error in my asp.net project when trying to execute the "Validator.RuleSet.Validate" :
"An exception occurred while validating an object:
Exception: 'The "GoldenHills.FastBird.Module.BusinessObjects.Orders.Order" class is not registered within the business model. To avoid this error, use the Module Designer (http://documentation.devexpress.com/#Xaf/CustomDocument2828)) to include the specified class into the module's AdditionalExportedTypes collection or manually register it via the XafTypesInfo.Instance.RegisterEntity(Type) method.'
Rule Id: 'DevExpress.Persistent.Validation.RuleUniqueValue_GoldenHills.FastBird.Module.BusinessObjects.Orders.Order_FBDNumber'
Rule Type: 'DevExpress.Persistent.Validation.RuleUniqueValue'
Target Object: '2014-18'"
The below is done in asp.net project that reference my XAF module:
using (var uow = ConnectionHelper.CreateObjectSpace())
{
try
{
Session session = ((XPObjectSpace)uow).Session;
GeneralSettings generalSettings = session.FindObject<GeneralSettings>(CriteriaOperator.Parse(String.Empty));
order = DataAccessHelper.GetObjectByKey<Order>(orderId, session);
order.OrderDate = orderDateEdit.Date;
order.ApprovalStatus = approvalStatus;
.
.
.
.
.
Validator.RuleSet.Validate(uow,order, "Save"); // RAISE AN ERROR
order.Save();
uow.CommitChanges();
return order;
}
catch (ValidationException vEx)
{
ShowError(vEx.Message, "Validation Error");
return null;
}
catch (Exception ex)
{
uow.Rollback();
ShowError(ex);
return null;
}
}