SeedData.cs.vm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Admin.NET.Core;
  2. using @Model.EntityNameSpace;
  3. namespace @Model.NameSpace;
  4. /// <summary>
  5. /// @(Model.Description) 表种子数据
  6. /// </summary>
  7. public class @(Model.SeedDataName): ISqlSugarEntitySeedData<@(Model.EntityName)>
  8. {
  9. /// <summary>
  10. /// 种子数据
  11. /// </summary>
  12. /// <returns></returns>
  13. public IEnumerable<@(Model.EntityName)> HasData()
  14. {
  15. string recordsJSON = @@"
  16. @(Model.RecordsJSON.Replace("\"","\"\"").Replace("\n", "\n\t\t\t"))
  17. ";
  18. List<@(Model.EntityName)> records = Newtonsoft.Json.JsonConvert.DeserializeObject<List<@(Model.EntityName)>>(recordsJSON);
  19. @if (Model.JsonIgnoreInfo.Count>0) {
  20. @:
  21. @:#region 处理 JsonIgnore 的Property
  22. @:
  23. @foreach (var jii in Model.JsonIgnoreInfo){
  24. @foreach (var j in jii){
  25. @:records[@j.RecordIndex].@(j.Name) = @(j.Value);
  26. }
  27. @:
  28. }
  29. @:#endregion
  30. }
  31. // 后处理数据的特殊字段
  32. //for (int i = 0; i < records.Count; i++) { }
  33. return records;
  34. }
  35. }