Home

Save cache when switching between connections

I noticed that when changing connections data saved with Util.Cache is cleared. It would be handy if there was a way to persist cache across connections.

A use case I have is comparing data between server instances. For example, I would like to cache some data under a qa key, switch to a staging server connection, and then cache some new data under a staging key.

Once both caches are populated I would do comparisons.

Thanks!

Comments

  • edited December 2020

    If you're sure that the two data models are equal, you can create another instance of the typed data context (or user query) to the staging environment.

    var conn1 = this;
    
    using var conn2 = new TypedDataContext(
      new SqlConnectionStringBuilder(Connection.ConnectionString) {
        DataSource = @"sql2\MSSQLSERVER"
      }.ConnectionString);
    
    Util.Dif(conn1.Products, conn2.Products).Dump();
    
Sign In or Register to comment.