|
@@ -19,43 +19,34 @@ namespace InABox.Core
|
|
|
public static IEnumerable<ImportMapping> ExtractMappings(Type type, ImportMappingType Import)
|
|
|
{
|
|
|
var results = new List<ImportMapping>();
|
|
|
- var keys = CoreUtils.PropertyList(type, x => true, true).Keys.ToArray();
|
|
|
- foreach (var key in keys)
|
|
|
+
|
|
|
+ var props = DatabaseSchema.Properties(type).OrderBy(x=>x.Sequence);
|
|
|
+
|
|
|
+ //var keys = CoreUtils.PropertyList(type, x => true, true).Keys.ToArray();
|
|
|
+ foreach (var prop in props)
|
|
|
{
|
|
|
- var prop = CoreUtils.GetProperty(type, key);
|
|
|
- var editor = prop.GetEditor();
|
|
|
- if (editor != null && editor is NullEditor == false && (!prop.IsCalculated() || Import == ImportMappingType.Export))
|
|
|
+
|
|
|
+ if (prop.Editor != null && prop.Editor is NullEditor == false && (!prop.IsCalculated || Import == ImportMappingType.Export))
|
|
|
{
|
|
|
var bOK = true;
|
|
|
|
|
|
- var bKey = editor is UniqueCodeEditor;
|
|
|
+ var bKey = prop.Editor is UniqueCodeEditor;
|
|
|
|
|
|
var lookup = ImportLookupType.None;
|
|
|
if (Import == ImportMappingType.Import)
|
|
|
{
|
|
|
- var parentkey = string.Join(".", key.Split('.').Reverse().Skip(1).Reverse());
|
|
|
- var childkey = key.Split('.').Last();
|
|
|
- if (!string.IsNullOrEmpty(parentkey))
|
|
|
+ var comps = prop.Name.Split('.');
|
|
|
+ if (comps.Length > 1)
|
|
|
{
|
|
|
- var parentprop = CoreUtils.GetProperty(type, parentkey);
|
|
|
- if (parentprop.PropertyType.GetInterfaces().Contains(typeof(IEntityLink)))
|
|
|
- {
|
|
|
- if (!IsNestedEntityLink(type, parentkey))
|
|
|
- {
|
|
|
- bOK = editor is CodeEditor;
|
|
|
- lookup = ImportLookupType.Restrict;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- bOK = false;
|
|
|
- lookup = ImportLookupType.None;
|
|
|
- }
|
|
|
- }
|
|
|
+ if ((comps.Length == 2) && (prop.Editor is CodeEditor))
|
|
|
+ lookup = ImportLookupType.Restrict;
|
|
|
+ else
|
|
|
+ bOK = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (bOK)
|
|
|
- results.Add(new ImportMapping { Property = key, Field = "", Constant = "", Lookup = lookup, Key = bKey });
|
|
|
+ results.Add(new ImportMapping { Property = prop.Name, Field = "", Constant = "", Lookup = lookup, Key = bKey });
|
|
|
}
|
|
|
}
|
|
|
|