protected override IComondModul <IMyEntity> СommandStart(IComondModul <IMyEntity> comond)
        {
            if (comond.Action == TypeComond.Get)
            {
                IEnumerable <IMyEntity> user = mainContext.GetEntity(comond.TypeModel);

                comond.SetAnswer(user);
            }
            else if (comond.Action == TypeComond.Сreate)
            {
                IMyEntity         ответ = mainContext.CreatEntity(comond.TypeModel);
                IList <IMyEntity> user  = new List <IMyEntity> {
                    ответ
                };
                comond.SetAnswer(user);
            }
            else if (comond.Action == TypeComond.Remove)
            {
                mainContext.RemoveEntity(comond.Data);
                comond.SetAnswer(comond.Data);
            }
            else if (comond.Action == TypeComond.Save)
            {
                mainContext.SaveChangesAsync();
            }
            else if (comond.Action == TypeComond.GetTable)
            {
                comond.Metadata = mainContext.GetTable();
            }
            return(comond);
        }
Example #2
0
        static void Main(string[] args)
        {
            using (MainContext var = new MainContext("Krypto"))
            {
                // var.Database.Migrate();
                List <User>  enetable = var.UserDates.ToList();
                List <WebIP> webIPs   = var.WebIPes.ToList();

                foreach (ITable table in  var.GetTable())
                {
                    Console.WriteLine($"Tаблица {table.TypeEntity}");
                    IEnumerable <IMyEntity> myEntities = var.GetEntity(table.TypeEntity);
                    foreach (IMyEntity entity in myEntities)
                    {
                        Console.WriteLine($"     id={entity.Id}  {entity.ToString()}.");
                    }
                }
            }

            Console.ReadKey();
        }