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


C# DataContext.GetCommand方法代码示例

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


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

示例1: CreateDataContext

        public void CreateDataContext()
        {
            string connectionString = "DbLinqProvider=Sqlite;" + 
                "DbLinqConnectionType=Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite;" + 
                "Data Source=Northwind.db3";
            var dc = new DataContext(connectionString);
            Assert.AreEqual(typeof(SqliteConnection), dc.Connection.GetType());

            var dcq = from p in dc.GetTable<Product>() where p.ProductName == "Chai" select p.ProductID;
            var cmd = dc.GetCommand(dcq);
            var dcc = dcq.ToList().Count;
            Assert.AreEqual(dcc, 1);
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:DirectDataContext.cs

示例2: WriteLog

 /// <summary>
 /// 用于Linq写Log
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="query"></param>
 /// <param name="IsWriteSql"></param>
 public static void WriteLog(DataContext dc, IQueryable query, bool IsWriteSql)
 {
     if (IsWriteSql)
     {
         DbCommand cmd = dc.GetCommand(query);
         WriteLog(cmd.CommandText);
     }
 }
开发者ID:gudaling,项目名称:hotel,代码行数:14,代码来源:CommonLibrary.cs

示例3: GetFullQueryInfo

        private SqlQueryText[] GetFullQueryInfo(DataContext dataContext, IQueryable query)
        {
            System.Data.Common.DbCommand dbCommand = dataContext.GetCommand(query);

            SqlQueryText[] result = new SqlQueryText[1];
            for (int i = 0, n = 1; i < n; i++) {
                result[i].Text = dbCommand.CommandText;
                int nParams = dbCommand.Parameters.Count ;
                result[i].Params = new ParameterText[nParams];
                for (int j = 0; j < nParams; j++) {
                    ParameterText param = new ParameterText();
                    System.Data.Common.DbParameter pInfo = dbCommand.Parameters[j];
                    param.Name = pInfo.ParameterName;
                    param.SqlType = pInfo.DbType.ToString();
                    Console.WriteLine("Before SqlType= " + param.SqlType);
                    object paramValue = pInfo.Value;
                    if (paramValue == null) {
                        param.Value = null;
                    } else {
                        param.Value = pInfo.Value.ToString();
                    }
                    result[i].Params[j] = param;
                }
            }
            return result;
        }
开发者ID:zhang5171291,项目名称:TestCode,代码行数:26,代码来源:SqlServerQueryVisualizer.cs


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