예제 #1
0
        /// <summary>
        /// Formats a field for select clause
        /// </summary>
        /// <param name="field">The field</param>
        /// <returns>SQL Fragment</returns>
        public string FormatForSelectClause(IFormatableField field)
        {
            string fieldName = Format(field);
            if (field.Alias != null)
                fieldName += " AS [" + field.Alias + "]";

            return fieldName;
        }
예제 #2
0
        public void ToString_WithMoreThanOneField_GeneratesCorrectSQLClause()
        {
            var table = new Tables_Blogs();

            var fields = new IFormatableField[]
                         	{
                         		new Tables_Blogs_Id(table),
                         		new Tables_Blogs_Name(table)
                         	};

            var select = new SelectClause(fields);

            string expected =
                @"SELECT
                [dbo].[Blogs].[Id],
                [dbo].[Blogs].[Name]
            ";

            Assert.AreEqual(expected, select.ToString());
        }
예제 #3
0
 /// <summary>
 /// Formats a field
 /// </summary>
 /// <param name="field">The field</param>
 /// <returns>SQL Fragment</returns>
 public string Format(IFormatableField field)
 {
     return field.Table + ".[" + field.Name + "]";
 }