Skip to content

Commit c3b6af5

Browse files
committed
feat(document-builder): use the meta builder
1 parent a82aade commit c3b6af5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/JsonApiDotNetCore/Builders/DocumentBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ public Documents Build(IEnumerable<IIdentifiable> entities)
6262
private Dictionary<string, object> _getMeta(IIdentifiable entity)
6363
{
6464
if (entity == null) return null;
65-
66-
var meta = new Dictionary<string, object>();
67-
var metaEntity = entity as IHasMeta;
6865

69-
if(metaEntity != null)
70-
meta = metaEntity.GetMeta(_jsonApiContext);
66+
var builder = _jsonApiContext.MetaBuilder;
67+
68+
if(entity is IHasMeta metaEntity)
69+
builder.Add(metaEntity.GetMeta(_jsonApiContext));
7170

7271
if(_jsonApiContext.Options.IncludeTotalRecordCount)
73-
meta["total-records"] = _jsonApiContext.PageManager.TotalRecords;
72+
builder.Add("total-records", _jsonApiContext.PageManager.TotalRecords);
7473

74+
var meta = builder.Build();
7575
if(meta.Count > 0) return meta;
7676
return null;
7777
}

0 commit comments

Comments
 (0)