How to get access to NOT NULL/Maxlength generated properties
How to get access to NOT NULL/Maxlength generated properties
Hello,
(Devart dotConnect for Oracle 6.0.10.0; Devart EntityDeveloper 3.0.10.0)
I want to validate my objects and create error-messages.
For every generated class I write my own partial methods like this:
public partial class classXX: IDataErrorInfo
{
...
partial void OnINFOChanging(string value)
{
if (string.IsNullOrEmpty(value)) ...
if (value.Length > ....)
}
This is a lot of typing, becaue most the fields have these same checks (NOT NULL and stringlength).
When entityDeveloper creates the entities he sees these values. How can I get access to these values/attributes/properties ?
[/code]
(Devart dotConnect for Oracle 6.0.10.0; Devart EntityDeveloper 3.0.10.0)
I want to validate my objects and create error-messages.
For every generated class I write my own partial methods like this:
public partial class classXX: IDataErrorInfo
{
...
partial void OnINFOChanging(string value)
{
if (string.IsNullOrEmpty(value)) ...
if (value.Length > ....)
}
This is a lot of typing, becaue most the fields have these same checks (NOT NULL and stringlength).
When entityDeveloper creates the entities he sees these values. How can I get access to these values/attributes/properties ?
[/code]
You can use code like the following:
Code: Select all
MetadataWorkspace mw = context.MetadataWorkspace;
var entity = mw.GetItems(DataSpace.CSpace).Where(it => it.Name == "").Single();
foreach (EdmProperty property in entity.Members) {
foreach (var facet in property.TypeUsage.Facets) {
if (facet.Name == "Nullable") {
//The property is nullable
}
else if (facet.Name == "MaxLength") {
int maxLength = (int)facet.Value;
}
}
}