mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
resolve CA1062 warning
This commit is contained in:
parent
1ef88f2964
commit
7192d1d1b6
1 changed files with 11 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Ardalis.GuardClauses;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.Seed.Extensions
|
||||
|
|
@ -9,16 +10,17 @@ public static class SeedExtension
|
|||
{
|
||||
public static void HasDataJsonFile<TEntity>(this EntityTypeBuilder entityTypeBuilder)
|
||||
{
|
||||
string path = Path.Combine("../../../data", $"{typeof(TEntity).Name}.json");
|
||||
if (File.Exists(path))
|
||||
Guard.Against.Null(entityTypeBuilder, nameof(entityTypeBuilder));
|
||||
|
||||
var path = Path.Combine("../../../data", $"{typeof(TEntity).Name}.json");
|
||||
if (!File.Exists(path)) return;
|
||||
|
||||
var entitiesJson = File.ReadAllText(path);
|
||||
var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson, new JsonSerializerOptions
|
||||
{
|
||||
var entitiesJson = File.ReadAllText(path);
|
||||
var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
});
|
||||
entityTypeBuilder.HasData((IEnumerable<object>)entities);
|
||||
}
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
});
|
||||
entityTypeBuilder.HasData((IEnumerable<object>)entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue