public FluentSqlBuilder <TTableJoin> AddJoinCommon <TTableLeft, TTableJoin>(Expression <Func <TTableLeft, TTableJoin, bool> > expression, JoinType joinType, TargetToSelect targetToSelect, string tableAlias = null) { var sqlBuilderFluentJoin = new FluentSqlBuilder <TTableJoin>(_sqlQueryBuilder, _resolver, targetToSelect); _resolver.AddJoinByType(expression, joinType, tableAlias); return(sqlBuilderFluentJoin); }
public FluentSqlBuilder <TTable> From <TTable>(string tableAlias = null) { var sqlBuilder = new FluentSqlBuilder <TTable>(_fluentSqlBuilderMiddlewareOptions.SqlAdapterType, _fluentSqlBuilderMiddlewareOptions.Formatting, tableAlias); return(sqlBuilder); }
static void Main() { PrintMenu(); while (true) { Console.Write("\n\nCHOOSE AN OPTION: "); var numberMenu = Console.ReadLine(); var numberMenuParsed = int.TryParse(numberMenu, out int numberMenuParse); if (numberMenuParsed) { Console.Clear(); PrintMenu(numberMenuParse); FluentSqlBuilder <OrderDataModel> fluentSqlBuilderOrder = null; FluentSqlBuilder <CustomerDataModel> fluentSqlBuilderCustomer = null; switch (numberMenuParse) { case 1: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectSimple01(); break; case 2: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithInnerJoin02(); break; case 3: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithLeftJoin03(); break; case 4: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithRightJoin04(); break; case 5: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithWhere05(); break; case 6: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithWhereAndInnerJoin06_01(); break; case 7: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithWhereAndInnerJoin07_02(); break; case 8: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithOrderBy08(); break; case 9: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithOrderByDescendingBy09(); break; case 10: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithGroupBy10(); break; case 11: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithGroupByAndHaving11(); break; case 12: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithProjection12(); break; case 13: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithLimit13(); break; case 14: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithPagination14(); break; case 15: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithAlias15(); break; case 16: fluentSqlBuilderCustomer = FluentSqlBuilderRepository.SelectWithFull16(); break; case 17: fluentSqlBuilderOrder = FluentSqlBuilderRepository.SelectWithDistinct17(); break; default: throw new ArgumentException("Number invalid"); } string sqlSelect = null; object data = null; if (fluentSqlBuilderOrder != null) { sqlSelect = fluentSqlBuilderOrder.ToString(); var parameters = fluentSqlBuilderOrder.GetParameters(); data = ExecuteQuery <OrderDataModel>(sqlSelect, parameters); } else if (fluentSqlBuilderCustomer != null) { sqlSelect = fluentSqlBuilderCustomer.ToString(); var parameters = fluentSqlBuilderCustomer.GetParameters(); data = ExecuteQuery <CustomerDataModel>(sqlSelect, parameters); } Console.WriteLine("\n\n----------- SQL -----------\n\n "); Console.WriteLine(DefineColorInSelect(sqlSelect)); Console.WriteLine(); if (_executeInBD) { var optionsJson = new JsonSerializerOptions() { WriteIndented = true }; var dataJson = JsonSerializer.Serialize(data, optionsJson); Console.WriteLine("\n\n----------- JSON -----------\n\n "); Console.WriteLine(dataJson); } } else { throw new ArgumentException("Number invalid"); } } }