Skip to content

Commit

Permalink
[C#] Fix import column manquant des fois
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Nov 15, 2023
1 parent e4a4803 commit 1e37d6e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TopModel.Generator.Csharp/CSharpClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ private void GenerateUsings(CSharpWriter w, Class item, string tag)
if (item.Properties.Any(p => p is CompositionProperty) ||
item.Properties.OfType<IFieldProperty>().Any(fp =>
{
var prop = fp is AliasProperty alp ? alp.Property : fp;
return (!Config.NoColumnOnAlias || fp is not AliasProperty) && prop.Class.IsPersistent && !Config.NoPersistence(tag) && Classes.Contains(prop.Class);
var prop = (fp as AliasProperty)?.PersistentProperty ?? fp;
return (fp.Class.IsPersistent || fp is AliasProperty { PersistentProperty: not null, As: null } && !Config.NoColumnOnAlias)
&& Classes.Contains(prop.Class)
&& !Config.NoPersistence(tag);
}))
{
usings.Add("System.ComponentModel.DataAnnotations.Schema");
Expand Down

0 comments on commit 1e37d6e

Please sign in to comment.