Created
January 15, 2015 09:34
-
-
Save TWolverson/3db1a7aee8731103679b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReferenceValuesService{ | |
public ReferenceValuesService(Func<Context> contextFactory){ | |
this.contextFactory = contextFactory; | |
this.referenceValues = new Lazy<IEnumerable<ReferenceValue>>(() => this.contextFactory().GetReferenceValues()); | |
} | |
public IEnumerable<ReferenceValue> ReferenceValues(){ | |
return this.referenceValues.Value; | |
} | |
private readonly Lazy<IEnumerable<ReferenceValue>> referenceValues; | |
} | |
public class Context : DbContext{ | |
public virtual ObjectResult<ReferenceValue> GetReferenceValues(){ | |
//Entity Framework cruft | |
} | |
} | |
// instantiate ReferenceValuesService as new ReferenceValuesService(() => new Context()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment