public IEnumerable <Store1> ReadInStore()
        {
            var getPizza = from P in PC.Store
                           select MapStore.Map(P);

            return(getPizza);
        }
 public void CreateStore(Store1 Store)
 {
     //if (PC.CxOrder.Any(c => c.OrderId == order.) || order.Phone == null)
     //{
     //    Console.WriteLine($"This order with username {order.Username} already exists and cannot be added");
     //    return;
     //}
     //else
     PC.Store.Add(MapStore.Map(Store)); // this will generate insertMapper.Map(order)
     PC.SaveChanges();                  // this will execute the above generate insert query
 }
 public Term Visit(MapStore mapStore)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
        public Expr MapStore(Expr map, Expr value, params Expr[] indices)
        {
            if (!map.Type.IsMap)
            {
                throw new ExprTypeCheckException("map must be of map type");
            }

            if (indices.Length < 1)
            {
                throw new ArgumentException("Must pass at least one index");
            }

            if (map.Type.AsMap.MapArity != indices.Length)
            {
                throw new ArgumentException("the number of arguments does not match the map arity");
            }

            if (!map.Type.AsMap.Result.Equals(value.Type))
            {
                throw new ExprTypeCheckException("value (" + value.Type.ToString() + ") must match map's result type (" + map.Type.AsMap.Result.ToString() + ")");
            }

            // Use Cache
            MapStore ms = null;

            try
            {
                ms = MapStoreCache[indices.Length];
            }
            catch (KeyNotFoundException)
            {
                ms = new MapStore(Token.NoToken, indices.Length);
                MapStoreCache[indices.Length] = ms;
            }


            // Type check each argument
            foreach (var typePair in map.Type.AsMap.Arguments.Zip(indices.Select(i => i.ShallowType)))
            {
                if (!typePair.Item1.Equals(typePair.Item2))
                {
                    throw new ExprTypeCheckException("Map argument type mismatch. " + typePair.Item1.ToString() + " != " + typePair.Item2.ToString());
                }
            }

            // Build the argument list
            var argList = new List <Expr>()
            {
                map
            };                                      // First argument is map to add store to

            for (int index = 0; index < indices.Length; ++index)
            {
                argList.Add(indices[index]);
            }

            // Now add the last argument which is the value to store
            argList.Add(value);


            var result = GetNAry(ms, argList);

            result.Type = map.Type;
            return(result);
        }