public ActionResult GetUser(CustomerStruct viewModel)
        {
            //INSERT INTO [tblUsers]([id],[un],[password]) VALUES (1111,@un,@password)
            if (ModelState.IsValid)
            {
                PDBC db = new PDBC("MVCCNS", true);
                List <ExcParameters> paramss    = new List <ExcParameters>();
                ExcParameters        parameters = new ExcParameters()
                {
                    _KEY   = "@password",
                    _VALUE = viewModel.password
                };
                paramss.Add(parameters);
                parameters = new ExcParameters()
                {
                    _KEY   = "@un",
                    _VALUE = viewModel.name
                };

                paramss.Add(parameters);
                db.Connect();
                string res = db.Script("INSERT INTO [tblUsers]([id],[un],[password]) VALUES (1111,@un,@password)", paramss);
                return(Content(res));
            }
            else
            {
                ModelState.Values.ToString();
                return(Content("0"));
            }
        }
Esempio n. 2
0
        public void Execute()
        {
            WriteHeading(".NET version");
#if !COREFX
            Console.WriteLine(Environment.Version);
#endif
            RuntimeTypeModel orderModel = TypeModel.Create();
            orderModel.Add(typeof(OrderHeader), true);
            orderModel.Add(typeof(OrderDetail), true);

            PurgeWithGusto("OrderSerializer.dll");
            orderModel.Compile("OrderSerializer", "OrderSerializer.dll");
            PEVerify.Verify("OrderSerializer.dll");
            RuntimeTypeModel model = BuildMeta();
            Customer         cust1 = new Customer();
            CustomerStruct   cust2 = new CustomerStruct
            {
                Id   = cust1.Id = 123,
                Name = cust1.Name = "Fred"
            };
#if !FX11
            cust1.HasValue = cust2.HasValue = true;
            cust1.HowMuch  = cust2.HowMuch = 0.123;
#endif
            WriteCustomer(model, "Runtime - class", cust1);
            WriteCustomer(model, "Runtime - struct", cust2);

#if FEAT_COMPILER && !FX11
            model.CompileInPlace();
            WriteCustomer(model, "InPlace- class", cust1);
            WriteCustomer(model, "InPlace - struct", cust2);
#endif
#if FEAT_COMPILER
#if !COREFX
            PurgeWithGusto("CustomerModel.dll");
            TypeModel compiled = model.Compile("CustomerModel", "CustomerModel.dll");
            PEVerify.Verify("CustomerModel.dll");
            WriteCustomer(compiled, "Compiled - class", cust2);
            WriteCustomer(compiled, "Compiled - struct", cust2);
#endif

            /*
             * CustomerModel serializer = new CustomerModel();
             * using (MemoryStream ms = new MemoryStream())
             * {
             *  Customer cust = new Customer();
             *  cust.Id = 123;
             *  cust.Name = "Fred";
             *  serializer.Serialize(ms, cust);
             *  ms.Position = 0;
             *  Customer clone = (Customer)serializer.Deserialize(ms, null, typeof(Customer));
             *  Console.WriteLine(clone.Id);
             *  Console.WriteLine(clone.Name);
             * }
             */
#endif
        }
        static void Main(string[] args)
        {
            var a = new Customer(1, "A", "B");
            var b = new Customer(2, "A", "B");

            Console.WriteLine(a.Equals(b));
            Console.WriteLine(b.Equals(a));

            Console.WriteLine(a.CompareByLastName(b));
            Console.WriteLine(a.CompareTo(b));

            var aStruct = new CustomerStruct(1, "A", "B");
            var bStruct = new CustomerStruct(2, "A", "B");

            Console.WriteLine(aStruct.CompareByLastName(bStruct));
            Console.WriteLine(aStruct.CompareTo(bStruct));
            Console.Read();
        }