Skip to content

Commit

Permalink
fix: NRE in codegen for models with instance methods that lack a PK
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Sep 23, 2024
1 parent 52f8341 commit a86b432
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/IntelliTect.Coalesce/TypeDefinition/MethodViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ public IEnumerable<ParameterViewModel> ApiParameters
get
{
var parameters = ClientParameters;
if (IsModelInstanceMethod)
if (IsModelInstanceMethod && Parent.PrimaryKey != null)
{
parameters = new[]
{
new ImplicitParameterViewModel(
this,
Parent.PrimaryKey!,
Parent.PrimaryKey,
"id",
"Primary Key" // TODO: Is this what we want? Also, i18n.
"Primary Key"
)
}.Concat(parameters);
}
Expand Down
1 change: 0 additions & 1 deletion src/IntelliTect.Coalesce/Validation/ValidateContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public static ValidationHelper Validate(ReflectionRepository repository)
if (prop.ReferenceNavigationProperty is not null)
{
assert.IsNotNull(prop.ReferenceNavigationProperty.Object, "Object property related object not found.");
assert.IsNotNull(prop.ReferenceNavigationProperty.Object?.PrimaryKey, "No primary key on type of this ID's Navigation Property.");
}

if (prop.Type.IsCollection)
Expand Down

0 comments on commit a86b432

Please sign in to comment.