Exemplo n.º 1
0
        public string BuildSelectByLamda <TEntity, TResult>(Expression <Func <TEntity, bool> > expression, out object arguments, Expression <Func <TEntity, TResult> > select, string function)
        {
            List <string> columnExpression = new List <string>();
            string        columnNames      = _selectBuilder.BuildSelect(select);


            string table = this._dialectBuilder.GetTable(typeof(TEntity));

            string where = "";
            if (expression != null)
            {
                where = string.Format("WHERE {0}", BuildWhere <TEntity>(expression, out arguments));
            }
            else
            {
                arguments = new object();
            }
            string sql = string.Format("SELECT {0} FROM {1} {2}", columnNames, table, where);

            return(sql);
        }
        public void BuildSelect_One_column_string()
        {
            //Arrange
            Expression <Func <Entity_Select_Column_Test, string> > predicate = n => n.Code;
            //Action
            var actual = _builder.BuildSelect(predicate).Trim();
            // Assert
            var expected = "[Code]";

            Assert.AreEqual(expected, actual);
        }