Пример #1
0
        public static void Main(string[] args)
        {
            var myDto = new MyDto {
                Id = 1, IsDeleted = true
            };

            Spry.Select <MyDto>().Column(_ => myDto.Id).Column(_ => myDto.IsDeleted).From("tt")
            .InnerJoin("table2", "audit").On("c1", "d1")
            .InnerJoin("table3", "audit").On("c2", "d2")
            .InnerJoin("table4", "audit").On("c4", "d2")
            .InSchema("review")
            .Where(_ => myDto.Id).EqualTo(1)
            .AndWhere(_ => myDto.Id).InBetween(1, 10)
            .AndWhere(_ => myDto.Id).GreaterThan(5)
            .Build();

            Spry.InsertInto("tableOne", "review")
            .Value("One", 1)
            .Value(_ => myDto.Id)
            .OutputIdentity()
            .Execute(null);

            Spry.Update("tableOne")
            .Set(_ => myDto.Id)
            .Where <int>("id").EqualTo(1)
            .Execute(null);

            Console.ReadLine();
        }
Пример #2
0
 public Customer Read(int customerId)
 {
     using (var connection = _connectionFactory.CreateConnection())
     {
         return(Spry.Select <Customer>()
                .Column(_ => _.CustomerId, "C")
                .Column(_ => _.Name, "C")
                .Column(_ => _.DateOfBirth, "C")
                .From(CUSTOMER_TABLE).As("C").InSchema("dbo")
                .Where(_ => _.CustomerId, "C").EqualTo(customerId)
                .Query <Customer>(connection).SingleOrDefault());
     }
 }
Пример #3
0
        public Customer ReadComplete(int customerId)
        {
            using (var connection = _connectionFactory.CreateConnection())
            {
                var customer = Spry.Select <Customer>()
                               .Column(_ => _.CustomerId, "C")
                               .Column(_ => _.Name)
                               .Column(_ => _.DateOfBirth)
                               .Column(_ => _.Address.City)
                               .Column(_ => _.Address.Country)
                               .Column(_ => _.Address.PostCode)
                               .Column(_ => _.Address.CustomerAddressId)
                               .Column(_ => _.Address.LineOne)
                               .From(CUSTOMER_TABLE).As("C").InSchema("dbo")
                               .InnerJoin(CUSTOMER_ADDRESS_TABLE, "CA").On("CA.CustomerId", "C.CustomerId")
                               .Where(_ => _.CustomerId, "C").EqualTo(customerId)
                               .Query <dynamic>(connection).SingleOrDefault();

                return(ToCustomer(customer));
            }
        }