Ejemplo n.º 1
0
 private static void InsertingNewDataWithSubObjects(string fbConnectionString)
 {
     using (var db = new FirebirdContext(fbConnectionString))
     {
         var newItemid = db.Items.Max(c => c.Id) + 1;
         var newDetailId = db.Details.Max(c => c.Ident) + 1;
         db.Items.Add(new DbItem
         {
             Id = newItemid,
             Name = "Hello from code",
             LongText = "lorem ipsum dolor sit ammet",
             Details = new List<DbDetail> {
                 new DbDetail
                 {
                     Name = "Sub obj",
                     NumberValue = DateTime.Now.Second,
                     Date = DateTime.UtcNow,
                     FloatValue = DateTime.Now.Millisecond,
                     Ident = newDetailId,
                     ItemId = newItemid
                     },
                 new DbDetail
                 {
                     Name = "Sub obj",
                     NumberValue = DateTime.Now.Second,
                     Date = DateTime.UtcNow,
                     FloatValue = DateTime.Now.Millisecond,
                     Ident = newDetailId + 1,
                     ItemId = newItemid
                     }
             }
         });
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        private static void InsertingNewData(string fbConnectionString)
        {
            using (var db = new FirebirdContext(fbConnectionString))
            {
                db.Items.Add(new DbItem
                {
                    Id = db.Items.Max(c=>c.Id) + 1,
                    Name = "Hello from code",
                    LongText = "lorem ipsum dolor sit ammet"
                });

                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 private static void DisplayLastAdded(string fbConnectionString)
 {
     using (var db = new FirebirdContext(fbConnectionString))
     {
         var item = db.Items.ToList().Last();
         Console.WriteLine("last added item");
         Console.WriteLine(item.Id);
         Console.WriteLine(item.Name);
         Console.WriteLine(item.LongText);
         Console.WriteLine("\t\t details");
         foreach (var detail in item.Details)
         {
             Console.WriteLine(detail.Name);
             Console.WriteLine(detail.NumberValue);
             Console.WriteLine(detail.Date);
             Console.WriteLine(detail.FloatValue);
             Console.WriteLine(detail.Ident);
             Console.WriteLine(detail.ItemId);
         }
     }
 }
Ejemplo n.º 4
0
        private static void LazyLoadingSubObjects(string fbConnectionString)
        {
            using (var db = new FirebirdContext(fbConnectionString))
            {
                var item = db.Items.First();
                var details = item.Details.ToList();

                foreach (var detail in details)
                {
                    Console.WriteLine(detail.Name);
                    Console.WriteLine(detail.NumberValue);
                    Console.WriteLine(detail.Date);
                    Console.WriteLine(detail.FloatValue);
                    Console.WriteLine(detail.Ident);
                }
            }
        }
Ejemplo n.º 5
0
        private static void SimpleGetAll(string fbConnectionString)
        {
            using (var db = new FirebirdContext(fbConnectionString))
            {
                var views = db.Views.Select(v => new
                {
                    v.Name,
                    v.Id
                });

                ListAll(views);
            }
        }