private COASqlJoinData <T> MainJoinGeneator <T1>(Expression SetTables, object obj, COASqlJoinTypes type = COASqlJoinTypes.INNER, COADataBaseTypes databasetype = COADataBaseTypes.Sql) { var returnData = new COASqlJoinData <T>(); returnData.DataBaseType = databasetype; returnData.TableName = TableName; returnData.SetJoinType(type); var Column1Selected = Types.GetAllTypes(SetTables); var Selectedlist = new List <string>(); if (Column1Selected.Name.Count == 0) { var Types = GetGenericTypeList(obj); for (int i = 1; i < Types.Length; i++) { var Props = Types[i].GetProperties(); foreach (var prop in Props) { Selectedlist.Add($"{prop.ReflectedType.Name}.{prop.Name}"); } } } else { Selectedlist = Types.JoinBaseGenerator(Column1Selected); } returnData.SelectedColumns = Selectedlist; returnData.SqlQuery = Types.JoinSqlGenerator <T1>(returnData.SelectedColumns); return(returnData); }
public string PredicateToString(Expression predicate, COADataBaseTypes databasetype,bool join = false) { var Query = GetAllTypes(predicate); string str = " WHERE"; for (int i = 0; i < Query.Name.Count; i++) { if (Query.Type[i] == typeof(DateTime)) { var date = Convert.ToDateTime(Query.Value[i]); if (databasetype == COADataBaseTypes.Oracle) { if (date.Hour >= 1) Query.Value[i] = "TO_DATE('" + date.ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY/MM/DD HH:MI:SS')"; else Query.Value[i] += "TO_DATE('" + date.ToString("yyyy-MM-dd") + "', 'YYYY/MM/DD')"; } else { if (date.Second >= 1) Query.Value[i] = "'" + date.ToString("yyyy-MM-dd HH:mm:ss") + "'"; else Query.Value[i] += "'" + date.ToString("yyyy-MM-dd") + "'"; } } switch (Query.EqualType[i]) { case "Equal": str += " " + Query.Name[i] + " = " + Query.Value[i]; break; case "NotEqual": str += " " + Query.Name[i] + " != " + Query.Value[i]; break; case "GreaterThan": str += " " + Query.Name[i] + " > " + Query.Value[i]; break; case "GreaterThanOrEqual": str += " " + Query.Name[i] + " >= " + Query.Value[i]; break; case "LessThan": str += " " + Query.Name[i] + " < " + Query.Value[i]; break; case "LessThanOrEqual": str += " " + Query.Name[i] + " <= " + Query.Value[i]; break; case "Contains": str += " " + Query.Name[i] + " LIKE '%" + TurnChar(Query.Value[i]) + "%'"; break; case "StartsWith": str += " " + Query.Name[i] + " LIKE '" + TurnChar(Query.Value[i]) + "%'"; break; case "EndsWith": str += " " + Query.Name[i] + " LIKE '% " + TurnChar(Query.Value[i]) + "'"; break; } if (i <= Query.Name.Count - 2) { switch (Query.AndOr[i]) { case "And": str += " AND"; break; case "AndAlso": str += " AND"; break; case "Or": str += " OR"; break; case "OrElse": str += " OR"; break; } } } return str; }