Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,33 @@ public async Task TestFetchPrimaryKey()
}
}

/// <summary>
/// Test fetching primary key of a resolved entity from an abstract manifest.
/// </summary>
[TestMethod]
public async Task TestFetchAbstractPrimaryKey()
{
var corpus = TestHelper.GetLocalCorpus(testsSubpath, nameof(TestFetchAbstractPrimaryKey));
var doc = await corpus.FetchObjectAsync<CdmDocumentDefinition>("Account.cdm.json");

if (doc == null)
{
Assert.Fail($"Unable to load acccount.cdm.json. Please inspect error log for additional details.");
}

var entity = (CdmEntityDefinition)doc.Definitions[0];
var resolvedEntity = await entity.CreateResolvedEntityAsync("ResolvedAccount");
try
{
var pk = resolvedEntity.PrimaryKey;
Assert.IsNotNull(pk);
}
catch (Exception e)
{
Assert.Fail($"Exception occur while reading primary key for entity account. {e.Message}");
}
}

/// <summary>
/// Test setting and getting of data format
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ internal dynamic FetchPropertyValue(string propertyName, bool onlyFromProperty =
{
return attRef;
}
return ((CdmTypeAttributeDefinition)attRef).FetchObjectDefinitionName();
return ((CdmObject)attRef).FetchObjectDefinitionName();
}
break;
case "defaultValue":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"jsonSchemaSemanticVersion": "1.0.0",
"imports": [
{
"corpusPath": "cdm:/foundations.cdm.json"
}
],
"definitions": [
{
"entityName": "Account",
"hasAttributes": [
{
"name": "accountId",
"purpose": "identifiedBy",
"dataType": "entityId"
}
]
}
]
}