Ejemplo n.º 1
0
        public void Insert(ObjectLocation objectLocation)
        {
            using (var context = new MyDbContext())
            {
                context.Database.EnsureCreated();

                context.ObjectLocation.Add(objectLocation);

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public ObjectLocation GetObjectLocationId(int idObject, int idObjectLocation)
        {
            ObjectLocation objectRet = new ObjectLocation();

            using (var context = new MyDbContext()){
                var objects  = context.ObjectLocation;
                var objectsA = objects.Where(p => p.idObjectLocation == idObjectLocation && p.idObject == idObject).ToList();

                if (objectsA.Count > 0)
                {
                    objectRet = objectsA[0];
                }
            }

            return(objectRet);
        }
Ejemplo n.º 3
0
        public ObjectLocation GetObjectLocationUltimo(int idObject)
        {
            ObjectLocation objectRet = new ObjectLocation();

            using (var context = new MyDbContext()){
                var objects  = context.ObjectLocation;
                var objectsA = objects.Where(p => p.idObject == idObject).OrderByDescending(o => o.data).ToList();

                if (objectsA.Count > 0)
                {
                    objectRet = objectsA[0];
                }
            }

            return(objectRet);
        }