如何为班级清单状况做适当的纪念

时间:2019-01-09 10:07:24

标签: c# memento

我想在Farm类中为我的列表做备忘录,当我想保存它们的状态并例如通过字符串返回时,如果可能的话,不知道如何正确处理?

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

    namespace Farm
    {
        public class Farm
        {
            [Key]
            public int Id { get; set; } = 1;
            public string Name { get; set; }

            public virtual List<Stable> Stables { get; set; }
            public virtual List<Machine> Machines { get; set; }
            public virtual List<Worker> Workers { get; set; }
            public virtual List<ICultivation> Cultivations { get; set; }


            private Farm() { }
            private static readonly Farm farm = new Farm {  Name = "Farm" };

        }
    }

0 个答案:

没有答案