当前位置: 首页>>代码示例>>C#>>正文


C# ISqlDialect.ParseTableName方法代码示例

本文整理汇总了C#中ISqlDialect.ParseTableName方法的典型用法代码示例。如果您正苦于以下问题:C# ISqlDialect.ParseTableName方法的具体用法?C# ISqlDialect.ParseTableName怎么用?C# ISqlDialect.ParseTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISqlDialect的用法示例。


在下文中一共展示了ISqlDialect.ParseTableName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessSingleSideExpression

        static string ProcessSingleSideExpression(ISqlDialect dialect, Expression rootExpression, Expression e, IDictionary<string, object> parameters, Func<string> getParameterName)
        {
            switch (e.NodeType)
            {
                case ExpressionType.Parameter:
                    // This is used by DynamicSQLinqLambdaExpression
                    return "{FieldName}";

                case ExpressionType.Constant:
                    var val = GetExpressionValue(dialect, rootExpression, e, parameters, getParameterName);
                    return val.ToString();

                case ExpressionType.MemberAccess:
                    var dynExpr = ((dynamic)e).Expression;
                    if (dynExpr is ConstantExpression)
                    {
                        return GetExpressionValue(dialect, rootExpression, e, parameters, getParameterName);
                    }
                    if (dynExpr is MethodCallExpression)
                    {
                        throw new Exception("SqlExpression.ProcessSingleSideExpression: MethodCallExpression Unsupported");
                        /* **** TODO ****
                        var mce = (MethodCallExpression)dynExpr;
                        if (mce.Object is ConstantExpression)
                        {
                            var paramName = ProcessExpression(rootExpression, mce.Object, parameters, getParameterName);
                            return paramName; // BROKEN - Hit when calling a method within lambda expression
                        }
                        return ProcessCallExpression(rootExpression, mce, parameters, getParameterName);
                        */
                    }
                    else
                    {
                        var d = (dynamic)e;

                        if (
                            (d.NodeType == ExpressionType.MemberAccess && d.Expression == null) ||
                            (!IsPropertyExpressionRootParameter(rootExpression, e) && d.Expression.NodeType != ExpressionType.Parameter)
                        )
                        {
                            // A property of an object is being used as a query parameter
                            // This isn't the object that represents a column in the database
                            return GetExpressionValue(dialect, rootExpression, e, parameters, getParameterName);
                        }


                        // //////// Get Column Name to Use
                        var memberName = GetMemberColumnName(d.Member, dialect);
                        string methodName = null;

                        PropertyInfo pi = null;
                        try
                        {
                            if (d.Expression is MemberExpression)
                            {
                                pi = d.Expression.Member as PropertyInfo;
                            }
                            else
                            {
                                pi = null;
                            }
                        }
                        catch
                        {
                            pi = null;
                        }
                        if (pi != null)
                        {
                            if (pi.PropertyType == typeof(string))
                            {
                                if (memberName.ToLower() == "[length]")
                                {
                                    methodName = "LEN";
                                    memberName = GetMemberColumnName(pi, dialect);
                                }
                            }
                        }
                        else
                        {
                            memberName = string.Format("{0}", memberName);
                        }

                        // ////////////////////////////////////////////////////////////////

                        var addTableAlias = false; // true;
                        //if (this.JoinExpressions.Count == 0)
                        //{
                        //    if (this.Parent == null)
                        //    {
                        //        addTableAlias = false;
                        //    }
                        //}


                        // //////  Build full SQL to get data for expression
                        string fullMemberName;
                        if (addTableAlias)
                        {
                            // Get Table / View Name to Use
                            var tableName = dialect.ParseTableName(d.Expression.Name as String);
//.........这里部分代码省略.........
开发者ID:daywrite,项目名称:SQLinq,代码行数:101,代码来源:SqlExpressionCompiler.cs


注:本文中的ISqlDialect.ParseTableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。