public void Table_schema_name_set_to_default_values_if_names_not_provided()
 {
     using (var ctx = new DatabaseViewCacheContext(new Mock <DbConnection>().Object))
     {
         Assert.Equal("__ViewCache", ctx.TableName);
         Assert.Equal("dbo", ctx.SchemaName);
     }
 }
 /// <summary>
 /// Checks if the table storing cached views exists.
 /// </summary>
 /// <param name="viewCacheContext">
 /// An <see cref="DatabaseViewCacheContext"/> instance used to handle view caching.
 /// </param>
 /// <returns>
 /// <code>true</code> if table containing views exists. Otherwise <code>false</code>.
 /// </returns>
 protected override bool ViewTableExists(DatabaseViewCacheContext viewCacheContext)
 {
     return(viewCacheContext.Database.SqlQuery <int>(
                "SELECT COUNT(1) " +
                "FROM user_tables  " +
                "WHERE TABLE_NAME = upper('{1}') ",
                viewCacheContext.TableName)
            .Single() > 0);
 }
Exemple #3
0
 /// <summary>
 /// Checks if the table storing cached views exists.
 /// </summary>
 /// <param name="viewCacheContext">
 /// An <see cref="DatabaseViewCacheContext"/> instance used to handle view caching.
 /// </param>
 /// <returns>
 /// <code>true</code> if table containing views exists. Otherwise <code>false</code>.
 /// </returns>
 protected override bool ViewTableExists(DatabaseViewCacheContext viewCacheContext)
 {
     return(viewCacheContext.Database.SqlQuery <int>(
                "SELECT COUNT(1) " +
                "FROM INFORMATION_SCHEMA.TABLES " +
                "WHERE TABLE_SCHEMA = {0} " +
                "AND TABLE_NAME = {1}", viewCacheContext.SchemaName, viewCacheContext.TableName)
            .Single() > 0);
 }
 public void Can_set_table_schema_name()
 {
     using (var ctx = new DatabaseViewCacheContext(
                new Mock <DbConnection>().Object, "table", "schema"))
     {
         Assert.Equal("table", ctx.TableName);
         Assert.Equal("schema", ctx.SchemaName);
     }
 }
Exemple #5
0
 private DatabaseViewCacheEntry GetViews(DatabaseViewCacheContext dbViewCacheContext, string conceptualModelContainerName, string storeModelContainerName)
 {
     return
         (dbViewCacheContext
          .ViewCache
          .SingleOrDefault(
              e =>
              e.ConceptualModelContainerName == conceptualModelContainerName &&
              e.StoreModelContainerName == storeModelContainerName));
 }
        private XDocument DumpEdmx(DatabaseViewCacheContext context)
        {
            var stringBuilder = new StringBuilder();

            using (var writer = XmlWriter.Create(stringBuilder))
            {
                EdmxWriter.WriteEdmx(context, writer);
            }

            return(XDocument.Parse(stringBuilder.ToString()));
        }
Exemple #7
0
 /// <summary>
 /// Creates the table for storing views.
 /// </summary>
 /// <param name="viewCacheContext">
 /// An <see cref="DatabaseViewCacheContext"/> instance used to handle view caching.
 /// </param>
 /// <remarks>
 /// The table has to use <see cref="DatabaseViewCacheContext.TableName"/>
 /// and <see cref="DatabaseViewCacheContext.SchemaName"/> as table and schema names.
 /// </remarks>
 abstract protected void CreateViewTable(DatabaseViewCacheContext viewCacheContext);
Exemple #8
0
 /// <summary>
 /// Checks if the table storing cached views exists.
 /// </summary>
 /// <param name="viewCacheContext">
 /// An <see cref="DatabaseViewCacheContext"/> instance used to handle view caching.
 /// </param>
 /// <returns>
 /// <code>true</code> if table containing views exists. Otherwise <code>false</code>.
 /// </returns>
 abstract protected bool ViewTableExists(DatabaseViewCacheContext viewCacheContext);
 /// <summary>
 /// Creates the table for storing views.
 /// </summary>
 /// <param name="viewCacheContext">
 /// An <see cref="DatabaseViewCacheContext"/> instance used to handle view caching.
 /// </param>
 /// <remarks>
 /// The table has to use <see cref="DatabaseViewCacheContext.TableName"/>
 /// and <see cref="DatabaseViewCacheContext.SchemaName"/> as table and schema names.
 /// </remarks>
 protected override void CreateViewTable(DatabaseViewCacheContext viewCacheContext)
 {
     viewCacheContext.Database.ExecuteSqlCommand(
         (((IObjectContextAdapter)viewCacheContext).ObjectContext).CreateDatabaseScript());
 }