Select

normal and

Action<ISelector> selector = >{
    //equal to the sql: select firstName, lastName from yourtable where id = 1 and gender = 0
    List<YourType> list = selector.Return<YourType>("select firstName, lastName from yourtable", 
        reader=>new YourType{
            firstName = Convert.ToString(reader["firstName"]),
            lastName = Convert.ToString(reader["lastName"]),
        },
        new WhereClause(1, "id").And(new WhereClause(0, "gender")));
};


like

Action<ISelector> selector = >{
    //equal to the sql: select firstName, lastName from yourtable where id = 1 and Email like 'hello%'
    List<YourType> list = selector.Return<YourType>("select firstName, lastName from yourtable", 
        reader=>new YourType{
            firstName = Convert.ToString(reader["firstName"]),
            lastName = Convert.ToString(reader["lastName"]),
        },
        new WhereClause(1, "id").And(new LikeClause("Email", "hello", null, Comparison.RightLike)));
};

Update

Action<IUpdater> updater =>{
    //equal to the sql: update yourtable set firstName = "h1", lastName = "h2" where id = 1 and gender = 0
    updater.Update("yourtable", 
        new SqlValue[]
        {
            new SqlValue{
                  ColumnName = "firstName",
                  Value = "h1",
            },
            new SqlValue{
                   ColumnName = "lastName",
                   Value = "h2",
            }
         },
         new WhereClause(1, "gender")
    );

};

Insert

    //equal to the sql: insert into yourtable (firstName, lastName) values("h1","h2")
    Action<IInserter> inserter =>{
        inserter.Insert("yourtable",
            new SqlValue[]
            {
                new SqlValue{
                    ColumnName = "firstName",
                    Value = "h1",
                },
                new SqlValue{
                    ColumnName = "lastName",
                    Value = “h2",
                }
            });
    };

Last edited Jul 16, 2013 at 4:01 PM by czy, version 3

Comments

No comments yet.