public override string Translate(LambdaExpression expr) { //判断该Where查询是否为第一次访问,如果是第一次访问,则设置访问 if (TranslatorDelegate.IsFirstVisit(SectionType.Where)) { SqlBuilder.Append($" WHERE"); TranslatorDelegate.SetVisited(SectionType.Where); } Visit(expr.Body); return(SqlBuilder.ToString()); }
protected override Expression VisitMember(MemberExpression node) { var asc = _parameter.IsAsc ? "ASC" : "DESC"; SqlBuilder.Append(TranslatorDelegate.IsFirstVisit(SectionType.OrderBy) ? $"," : $" ORDER BY"); if (TranslatorDelegate.IsMultipleType()) { SqlBuilder.Append($" [{TranslatorDelegate.GetTypeAlias(node.Member.DeclaringType)}]."); } SqlBuilder.Append($"[{TranslatorDelegate.GetMemberMap(node.Member)}] {asc}"); return(base.VisitMember(node)); }