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


C# SQLiteConnection.GetSchema方法代码示例

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


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

示例1: using

    /// <summary>
    /// Creates temporary tables on the connection so schema information can be queried
    /// </summary>
    /// <remarks>
    /// There's a lot of work involved in getting schema information out of SQLite, but LINQ expects to
    /// be able to query on schema tables.  Therefore we need to "fake" it by generating temporary tables
    /// filled with the schema of the current connection.  We get away with making this information static
    /// because schema information seems to always be queried on a new connection object, so the schema is
    /// always fresh.
    /// </remarks>
    /// <param name="cnn">The connection upon which to build the schema tables.</param>
    void ISQLiteSchemaExtensions.BuildTempSchema(SQLiteConnection cnn)
    {
      string[] arr = new string[] { "TABLES", "COLUMNS", "VIEWS", "VIEWCOLUMNS", "INDEXES", "INDEXCOLUMNS", "FOREIGNKEYS", "CATALOGS" };

      using (DataTable table = cnn.GetSchema("Tables", new string[] { "temp", null, String.Format("SCHEMA{0}", arr[0]) }))
      {
        if (table.Rows.Count > 0) return;
      }

      for (int n = 0; n < arr.Length; n++)
      {
        using (DataTable table = cnn.GetSchema(arr[n]))
        {
          DataTableToTable(cnn, table, String.Format("SCHEMA{0}", arr[n]));
        }
      }

      using (SQLiteCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = Properties.Resources.SQL_CONSTRAINTS;
        cmd.ExecuteNonQuery();

        cmd.CommandText = Properties.Resources.SQL_CONSTRAINTCOLUMNS;
        cmd.ExecuteNonQuery();
      }
    }
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:37,代码来源:SQLiteProviderServices.cs

示例2: loadTableSchema

 //================================================================================================================================================================
 private DataTable loadTableSchema(string source, string[] restrictions, string schema, string name)
 {
     SQLiteConnection DBConnection = new SQLiteConnection(source);
     DBConnection.Open();
     DataTable dt = DBConnection.GetSchema(schema, restrictions);
     dt.TableName = name;
     DBConnection.Close();
     return dt;
 }
开发者ID:Miktor,项目名称:pub,代码行数:10,代码来源:Form1.cs


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