Skip to content

Commit

Permalink
use ServiceLookupEditor if no lookupscript, but it might lead to erro…
Browse files Browse the repository at this point in the history
…rs if there is no such List endpoint for the entity
  • Loading branch information
volkanceylan committed Oct 19, 2023
1 parent 0bb5c69 commit ed0780d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Serenity.Net.CodeGenerator/Generator/EntityModelGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,15 @@ void makeUniquePropertyName(EntityField f)
attrs.Add(new("Serenity.Data.Mapping.TextualField",
new RawCode("nameof(" + tableField.TextualField + ")")));

if (pkRow != null && pkPropertyIsId && pkRow.HasLookupScriptAttribute)
if (pkRow != null && pkPropertyIsId)
{
attrs.Add(new("Serenity.ComponentModel.LookupEditor", new TypeOfRef(pkRow.FullName),
new RawCode("Async = true")));
if (pkRow.HasLookupScriptAttribute)
attrs.Add(new("Serenity.ComponentModel.LookupEditor", new TypeOfRef(pkRow.FullName),
new RawCode("Async = true")));
// not yet implemented, it is not a trival task
// else if (!string.IsNullOrEmpty(pkRow.ListServiceRoute))
else
attrs.Add(new("Serenity.ComponentModel.ServiceLookupEditor", new TypeOfRef(pkRow.FullName)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public string NameProperty
}
}

public string ListServiceRoute => null;

public class RowPropertyMetadata : IRowPropertyMetadata
{
private readonly PropertyDefinition property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public interface IRowMetadata : IClassMetadata
IRowPropertyMetadata GetTableField(string columnName);
IRowPropertyMetadata GetProperty(string name);
bool HasLookupScriptAttribute { get; }
string ListServiceRoute { get; }
string IdProperty { get; }
string NameProperty { get; }
}

0 comments on commit ed0780d

Please sign in to comment.