massive

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Dynamic;

namespace ConsoleApplication1
{
    class Program
    {

        //  Https://github.com/robconery/massive

        static void Main(string[] args)
        {

            //fun1();

            //fun2();

            //fun3();

            //fun4();

            //fun5();

            //fun6();

            //fun7();
 
        }

        private static void fun7()
        {
            dynamic table = new Product();

            //var item = table.First(id: 1);
            //int id = item.Id;

            //var id = table.First(id:1).Id;

            //var count = table.Count();

            //var sum = table.Sum(columns:"id",id:3);

            //var sum = table.Max(columns: "id");


        }

        private static void fun6()
        {
            var table = new Product();
            var drinks = table.All();
            foreach (var item in drinks.ToArray())
            {
                item.Specification = "hello";
            }
            table.Save(drinks.ToArray());
        }

        private static void fun5()
        {
            var table = new Product();
            var newID = table.Insert(new { id = 11, Specification = "12345" });
        }

        private static void fun4()
        {
            var table = new Product();
            var poopy = new { Specification = "123" };
            table.Update(poopy, 3);  // update set  ="123" where id=3
        }

        private static void fun3()
        {
            //where id!=1 or id =2
            var table = new Product();
            var result = table.Query(@"select * from Product");
            var result1 = table.Paged(where: " where id!=1 ",
                                currentPage: 2,
                                pageSize: 2);

        }

        private static void fun2()
        {
            dynamic table = new Product();
            var productThree = table.Find(id: 3, columns: "Specification");
        }

        private static void fun1()
        {
            var table = new Product();
            var query = table.All().ToList();
            var productThree = table.All(columns: "Specification as sp",
                                         where: "where id=@0",
                                         args: 3);
        }

 

    
        
    }

    public class Product : DynamicModel
    {
        public Product()
            : base("TestProduct", "Product", "Id")
        {

        }


        public override void Validate(dynamic item)
        {
            //required
            ValidatesPresenceOf("id");
            //ValidatesNumericalityOf("id");
            if (item.id > 10)
                Errors.Add("id must less than 10");                       
        }
    }

}

转载于:https://www.cnblogs.com/rayrayray/archive/2012/08/31/2665288.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值