├── .nuget
├── NuGet.exe
├── _run.bat
├── NuGet.Config
└── NuGet.targets
├── EFSecondLevelCache
├── EnumerableExtentions.cs
├── DynamicEqualityComparer.cs
├── packages.config
├── Contracts
│ ├── IEFCacheKeyHashProvider.cs
│ ├── EFCacheDebugInfo.cs
│ ├── IEFCacheKeyProvider.cs
│ ├── EFCacheKey.cs
│ ├── EFCachePolicy.cs
│ └── IEFCacheServiceProvider.cs
├── Properties
│ └── AssemblyInfo.cs
├── EFCacheKeyHashProvider.cs
├── App.config
├── EFSecondLevelCache.nuspec
├── EFAsyncEnumerator.cs
├── EFCommandTreeCollector.cs
├── readme.txt
├── LinqToObjectsCacheKeyProvider.cs
├── FastReflectionUtils.cs
├── EFCachedQueryable.cs
├── EFCacheKeyProvider.cs
├── ObjectQueryExtensions.cs
├── XxHashUnsafe.cs
├── EFCommandTreeVisitor.cs
├── EFCacheServiceProvider.cs
├── EFCachedQueryExtension.cs
├── EFCachedQueryProvider.cs
└── EFSecondLevelCache.csproj
├── EFSecondLevelCache.Tests
├── EFSecondLevelCache.TestDataLayer
│ ├── packages.config
│ ├── Models
│ │ ├── Tag.cs
│ │ ├── User.cs
│ │ ├── TPT.cs
│ │ └── Product.cs
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── DataLayer
│ │ ├── SampleContext.cs
│ │ └── Configuration.cs
│ └── EFSecondLevelCache.TestDataLayer.csproj
├── EFSecondLevelCache.PerformanceTests
│ ├── packages.config
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── EFSecondLevelCache.PerformanceTests.csproj
├── EFSecondLevelCache.FunctionalDbFirstTests
│ ├── packages.config
│ ├── DBModel.cs
│ ├── DBModel.Designer.cs
│ ├── Tag.cs
│ ├── User.cs
│ ├── DBModel.edmx.diagram
│ ├── Product.cs
│ ├── DBModel.Context.cs
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── UnitTests.cs
│ └── EFSecondLevelCache.FunctionalDbFirstTests.csproj
├── EFSecondLevelCache.MockingTests
│ ├── packages.config
│ ├── App.config
│ ├── TestDbAsyncEnumerable.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TestDbAsyncQueryProvider.cs
│ ├── MockingTests.cs
│ └── EFSecondLevelCache.MockingTests.csproj
├── EFSecondLevelCache.FunctionalTests
│ ├── packages.config
│ ├── Bootstrapper.cs
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── PerformanceTests.cs
│ ├── EFCacheServiceProviderTests.cs
│ ├── EFSecondLevelCache.FunctionalTests.csproj
│ ├── CachedUserEntityTests.cs
│ └── DynamicLINQTests.cs
└── EFSecondLevelCache.UnitTests
│ ├── XxHashTests.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── EFSecondLevelCache.UnitTests.csproj
├── .github
└── issue_template.md
├── .gitattributes
├── README.md
├── .gitignore
└── EFSecondLevelCache.sln
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VahidN/EFSecondLevelCache/HEAD/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/EFSecondLevelCache/EnumerableExtentions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VahidN/EFSecondLevelCache/HEAD/EFSecondLevelCache/EnumerableExtentions.cs
--------------------------------------------------------------------------------
/EFSecondLevelCache/DynamicEqualityComparer.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VahidN/EFSecondLevelCache/HEAD/EFSecondLevelCache/DynamicEqualityComparer.cs
--------------------------------------------------------------------------------
/.nuget/_run.bat:
--------------------------------------------------------------------------------
1 | "%~dp0NuGet.exe" pack "..\EFSecondLevelCache\EFSecondLevelCache.csproj" -Prop Configuration=Release
2 | copy "%~dp0*.nupkg" "%localappdata%\NuGet\Cache"
3 | pause
--------------------------------------------------------------------------------
/EFSecondLevelCache/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.PerformanceTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.MockingTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/Models/Tag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace EFSecondLevelCache.TestDataLayer.Models
4 | {
5 | public class Tag
6 | {
7 | public int Id { set; get; }
8 | public string Name { set; get; }
9 |
10 | public virtual ICollection Products { set; get; }
11 | }
12 | }
--------------------------------------------------------------------------------
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 | # Summary of the issue
2 |
3 |
4 |
5 | ## Environment
6 |
7 | ```
8 | The in-use version:
9 | Operating system:
10 | IDE: (e.g. Visual Studio 2015)
11 | ```
12 |
13 | ## Example code/Steps to reproduce:
14 |
15 | ```
16 | paste your core code
17 | ```
18 |
19 | ## Output:
20 |
21 | ```
22 | Exception message:
23 | Full Stack trace:
24 | ```
25 |
26 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/DBModel.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/Models/User.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace EFSecondLevelCache.TestDataLayer.Models
5 | {
6 | public class User
7 | {
8 | public int Id { set; get; }
9 |
10 | [Required]
11 | public string Name { set; get; }
12 |
13 | public virtual ICollection Products { set; get; }
14 |
15 | public virtual ICollection Posts { set; get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache/Contracts/IEFCacheKeyHashProvider.cs:
--------------------------------------------------------------------------------
1 | namespace EFSecondLevelCache.Contracts
2 | {
3 | ///
4 | /// The CacheKey Hash Provider Contract.
5 | ///
6 | public interface IEFCacheKeyHashProvider
7 | {
8 | ///
9 | /// Computes the unique hash of the input.
10 | ///
11 | /// the input data to hash
12 | /// Hashed data
13 | string ComputeHash(string data);
14 | }
15 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/Models/TPT.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations.Schema;
2 |
3 | namespace EFSecondLevelCache.TestDataLayer.Models
4 | {
5 | public class Post
6 | {
7 | public int Id { get; set; }
8 | public string Title { get; set; }
9 |
10 | [ForeignKey("UserId")]
11 | public virtual User User { set; get; }
12 | public int UserId { set; get; }
13 | }
14 |
15 | [Table("Pages")]
16 | public class Page : Post
17 | {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/EFSecondLevelCache/Contracts/EFCacheDebugInfo.cs:
--------------------------------------------------------------------------------
1 | namespace EFSecondLevelCache.Contracts
2 | {
3 | ///
4 | /// Stores the debug information of the caching process.
5 | ///
6 | public class EFCacheDebugInfo
7 | {
8 | ///
9 | /// Stores information of the computed key of the input LINQ query.
10 | ///
11 | public EFCacheKey EFCacheKey { set; get; }
12 |
13 | ///
14 | /// Determines this query is using the 2nd level cache or not.
15 | ///
16 | public bool IsCacheHit { set; get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyTitle("EFSecondLevelCache")]
5 | [assembly: AssemblyDescription("Entity Framework Second Level Caching Library.")]
6 | [assembly: AssemblyConfiguration("")]
7 | [assembly: AssemblyCompany("Vahid N.")]
8 | [assembly: AssemblyProduct("EFSecondLevelCache")]
9 | [assembly: AssemblyCopyright("Copyright Vahid N. 2015")]
10 | [assembly: AssemblyTrademark("")]
11 | [assembly: AssemblyCulture("")]
12 |
13 | [assembly: ComVisible(false)]
14 | [assembly: Guid("77a71787-ef47-4d2d-8b6e-420ef339edd0")]
15 |
16 | [assembly: AssemblyVersion("1.2.0.0")]
17 | [assembly: AssemblyFileVersion("1.2.0.0")]
--------------------------------------------------------------------------------
/EFSecondLevelCache/EFCacheKeyHashProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EFSecondLevelCache.Contracts;
3 |
4 | namespace EFSecondLevelCache
5 | {
6 | ///
7 | /// Computes the unique hash of the input, using the xxHash algorithm.
8 | ///
9 | public class EFCacheKeyHashProvider : IEFCacheKeyHashProvider
10 | {
11 | ///
12 | /// Computes the unique hash of the input.
13 | ///
14 | /// the input data to hash
15 | /// Hashed data using the xxHash algorithm
16 | public string ComputeHash(string data)
17 | {
18 | if(string.IsNullOrWhiteSpace(data))
19 | throw new ArgumentNullException("data");
20 |
21 | return string.Format("{0:X}", XxHashUnsafe.ComputeHash(data));
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/DBModel.Designer.cs:
--------------------------------------------------------------------------------
1 | // T4 code generation is enabled for model 'D:\Prog\1393\EFSecondLevelCache\EFSecondLevelCache.Tests\EFSecondLevelCache.FunctionalDbFirstTests\DBModel.edmx'.
2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
4 | // is open in the designer.
5 |
6 | // If no context and entity classes have been generated, it may be because you created an empty model but
7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity
8 | // classes for your model, open the model in the designer, right-click on the designer surface, and
9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
10 | // Item...'.
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/Tag.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace EFSecondLevelCache.FunctionalDbFirstTests
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Tag
16 | {
17 | public Tag()
18 | {
19 | this.Products = new HashSet();
20 | }
21 |
22 | public int Id { get; set; }
23 | public string Name { get; set; }
24 |
25 | public virtual ICollection Products { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/User.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace EFSecondLevelCache.FunctionalDbFirstTests
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class User
16 | {
17 | public User()
18 | {
19 | this.Products = new HashSet();
20 | }
21 |
22 | public int Id { get; set; }
23 | public string Name { get; set; }
24 |
25 | public virtual ICollection Products { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.MockingTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/Models/Product.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 |
5 | namespace EFSecondLevelCache.TestDataLayer.Models
6 | {
7 | public class Product
8 | {
9 | [Key]
10 | public int ProductId { get; set; }
11 |
12 | [StringLength(30)]
13 | [Required]
14 | public string ProductNumber { get; set; }
15 |
16 | [StringLength(50)]
17 | [Required]
18 | [Index(IsUnique = true)]
19 | public string ProductName { get; set; }
20 |
21 | [StringLength(int.MaxValue)]
22 | public string Notes { get; set; }
23 |
24 | public bool IsActive { get; set; }
25 |
26 | public virtual ICollection Tags { set; get; }
27 |
28 | [ForeignKey("UserId")]
29 | public virtual User User { set; get; }
30 | public int UserId { set; get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/EFSecondLevelCache/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalTests/Bootstrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.Entity;
3 | using EFSecondLevelCache.TestDataLayer.DataLayer;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace EFSecondLevelCache.FunctionalTests
7 | {
8 | [TestClass]
9 | public class Bootstrapper
10 | {
11 | [AssemblyInitialize]
12 | public static void Initialize(TestContext context)
13 | {
14 | startDb();
15 | }
16 |
17 | [AssemblyCleanup]
18 | public static void AssemblyCleanup()
19 | {
20 | }
21 |
22 | private static void startDb()
23 | {
24 | AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory);
25 | Database.SetInitializer(new MigrateDatabaseToLatestVersion());
26 | using (var ctx = new SampleContext())
27 | {
28 | ctx.Database.Initialize(force: true);
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/EFSecondLevelCache/Contracts/IEFCacheKeyProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Linq.Expressions;
3 |
4 | namespace EFSecondLevelCache.Contracts
5 | {
6 | ///
7 | /// CacheKeyProvider Contract.
8 | ///
9 | public interface IEFCacheKeyProvider
10 | {
11 | ///
12 | /// Gets an EF query and returns its hash to store in the cache.
13 | ///
14 | /// Type of the entity
15 | /// The EF query.
16 | /// An expression tree that represents a LINQ query.
17 | /// Its default value is EF_.
18 | /// If you think the computed hash of the query is not enough, set this value.
19 | /// Information of the computed key of the input LINQ query.
20 | EFCacheKey GetEFCacheKey(IQueryable query, Expression expression, string keyHashPrefix = EFCacheKey.KeyHashPrefix, string saltKey = "");
21 | }
22 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.MockingTests/TestDbAsyncEnumerable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Data.Entity.Infrastructure;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 |
6 | namespace EFSecondLevelCache.MockingTests
7 | {
8 | public class TestDbAsyncEnumerable : EnumerableQuery, IDbAsyncEnumerable, IQueryable
9 | {
10 | public TestDbAsyncEnumerable(IEnumerable enumerable)
11 | : base(enumerable)
12 | { }
13 |
14 | public TestDbAsyncEnumerable(Expression expression)
15 | : base(expression)
16 | { }
17 |
18 | public IDbAsyncEnumerator GetAsyncEnumerator()
19 | {
20 | return new EFAsyncEnumerator(this.AsEnumerable().GetEnumerator());
21 | }
22 |
23 | IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
24 | {
25 | return GetAsyncEnumerator();
26 | }
27 |
28 | IQueryProvider IQueryable.Provider
29 | {
30 | get { return new TestDbAsyncQueryProvider(this); }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/DBModel.edmx.diagram:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/EFSecondLevelCache/EFSecondLevelCache.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EFSecondLevelCache
5 | $version$
6 | Vahid Nasiri
7 | Vahid Nasiri
8 | https://github.com/VahidN/EFSecondLevelCache/blob/master/LICENSE.md
9 | https://github.com/VahidN/EFSecondLevelCache
10 | false
11 | $description$
12 | $description$
13 | en-US
14 | EntityFramework Cache Caching SecondLevelCache EF6 ORM Interceptor
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/Product.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace EFSecondLevelCache.FunctionalDbFirstTests
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Product
16 | {
17 | public Product()
18 | {
19 | this.Tags = new HashSet();
20 | }
21 |
22 | public int ProductId { get; set; }
23 | public string ProductNumber { get; set; }
24 | public string ProductName { get; set; }
25 | public string Notes { get; set; }
26 | public bool IsActive { get; set; }
27 | public int UserId { get; set; }
28 |
29 | public virtual User User { get; set; }
30 | public virtual ICollection Tags { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/DBModel.Context.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace EFSecondLevelCache.FunctionalDbFirstTests
11 | {
12 | using System;
13 | using System.Data.Entity;
14 | using System.Data.Entity.Infrastructure;
15 |
16 | public partial class TestDB2015Entities : DbContext
17 | {
18 | public TestDB2015Entities()
19 | : base("name=TestDB2015Entities")
20 | {
21 | }
22 |
23 | protected override void OnModelCreating(DbModelBuilder modelBuilder)
24 | {
25 | throw new UnintentionalCodeFirstException();
26 | }
27 |
28 | public virtual DbSet Products { get; set; }
29 | public virtual DbSet Tags { get; set; }
30 | public virtual DbSet Users { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/EFSecondLevelCache/Contracts/EFCacheKey.cs:
--------------------------------------------------------------------------------
1 | namespace EFSecondLevelCache.Contracts
2 | {
3 | ///
4 | /// Stores information of the computed key of the input LINQ query.
5 | ///
6 | public class EFCacheKey
7 | {
8 | ///
9 | /// Its default value is EF_.
10 | ///
11 | public const string KeyHashPrefix = "EF_";
12 |
13 | ///
14 | /// The computed key of the input LINQ query.
15 | ///
16 | public string Key { set; get; }
17 |
18 | ///
19 | /// Hash of the input LINQ query's computed key.
20 | ///
21 | public string KeyHash { set; get; }
22 |
23 | ///
24 | /// Determines which entities are used in this LINQ query.
25 | /// This array will be used to invalidate the related cache of all related queries automatically.
26 | ///
27 | public string[] CacheDependencies { set; get; }
28 |
29 | ///
30 | /// Stores information of the computed key of the input LINQ query.
31 | ///
32 | public EFCacheKey()
33 | {
34 | CacheDependencies = new[] { string.Empty };
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.PerformanceTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.UnitTests/XxHashTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 |
3 | namespace EFSecondLevelCache.UnitTests
4 | {
5 | internal sealed class TestConstants
6 | {
7 | public static readonly string Empty = "";
8 | public static readonly string FooBar = "foobar";
9 | public static readonly string LoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ornare aliquam mauris, at volutpat massa. Phasellus pulvinar purus eu venenatis commodo.";
10 | }
11 |
12 | [TestClass]
13 | public class XxHashTests
14 | {
15 | [TestMethod]
16 | public void TestEmptyXxHashReturnsCorrectValue()
17 | {
18 | var hash = XxHashUnsafe.ComputeHash(TestConstants.Empty);
19 | Assert.AreEqual((uint)0x02cc5d05, hash);
20 | }
21 |
22 | [TestMethod]
23 | public void TestFooBarXxHashReturnsCorrectValue()
24 | {
25 | var hash = XxHashUnsafe.ComputeHash(TestConstants.FooBar);
26 | Assert.AreEqual((uint)2348340516, hash);
27 | }
28 |
29 | [TestMethod]
30 | public void TestLoremIpsumXxHashReturnsCorrectValue()
31 | {
32 | var hash = XxHashUnsafe.ComputeHash(TestConstants.LoremIpsum);
33 | Assert.AreEqual((uint)4046722717, hash);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalDbFirstTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EFSecondLevelCache.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EFSecondLevelCache.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("19693e05-0400-4f17-9f99-dbd75a9f3c48")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.MockingTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EFSecondLevelCache.MockingTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EFSecondLevelCache.MockingTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("86e6d7cf-1fb7-4e35-8c00-54efbc08ca2b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.TestDataLayer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EFSecondLevelCache.TestDataLayer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EFSecondLevelCache.TestDataLayer")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("aa31ad86-f876-453e-bed0-8753da988bbf")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.FunctionalTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EFSecondLevelCache.FunctionalTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EFSecondLevelCache.FunctionalTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f6fed369-7d8d-4ad6-b83c-be1f8d95f1a1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.PerformanceTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EFSecondLevelCache.PerformanceTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EFSecondLevelCache.PerformanceTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("fa46725a-66d3-48cc-8a1f-a2903eed346b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EFSecondLevelCache.Tests/EFSecondLevelCache.MockingTests/TestDbAsyncQueryProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Entity.Infrastructure;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace EFSecondLevelCache.MockingTests
8 | {
9 | public class TestDbAsyncQueryProvider : IDbAsyncQueryProvider
10 | {
11 | private readonly IQueryProvider _inner;
12 |
13 | public TestDbAsyncQueryProvider(IQueryProvider inner)
14 | {
15 | _inner = inner;
16 | }
17 |
18 | public IQueryable CreateQuery(Expression expression)
19 | {
20 | return new TestDbAsyncEnumerable(expression);
21 | }
22 |
23 | public IQueryable CreateQuery(Expression expression)
24 | {
25 | return new TestDbAsyncEnumerable(expression);
26 | }
27 |
28 | public object Execute(Expression expression)
29 | {
30 | return _inner.Execute(expression);
31 | }
32 |
33 | public TResult Execute(Expression expression)
34 | {
35 | return _inner.Execute(expression);
36 | }
37 |
38 | public Task