Created
May 24, 2016 04:13
-
-
Save mishrsud/8f65bc4fe085e11ce0d5c5d00770ab44 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
| // The type to be persisted | |
| using System; | |
| using Newtonsoft.Json; | |
| namespace Demo | |
| { | |
| public class SomeConfiguration | |
| { | |
| /// <summary> | |
| /// Gets or sets the identifier for this record. | |
| /// </summary> | |
| [JsonIgnore] | |
| public Guid Id { get; set; } | |
| /// <summary> | |
| /// Gets or sets the environment. | |
| /// </summary> | |
| public Environment Environment { get; set; } | |
| /// <summary> | |
| /// Gets or sets the | |
| /// </summary> | |
| public string Accept { get; set; } | |
| /// <summary> | |
| /// Gets or sets the | |
| /// </summary> | |
| public string AcceptEncoding { get; set; } | |
| } | |
| } | |
| // the Enum | |
| using System.ComponentModel; | |
| namespace Demo | |
| { | |
| /// <summary> | |
| /// The environment context for the configuration data | |
| /// </summary> | |
| public enum Environment | |
| { | |
| /// <summary> The development environment </summary> | |
| [Description("Development")] | |
| Development, | |
| /// <summary> The test environment </summary> | |
| [Description("Test")] | |
| Test, | |
| /// <summary> The regression environment </summary> | |
| [Description("Regression")] | |
| Regression, | |
| /// <summary> The production environment </summary> | |
| [Description("Production")] | |
| Production | |
| } | |
| } | |
| // Save to LiteDB as ususal | |
| // This works | |
| SomeConfiguration configuration = someConfigurationCollection.Find( | |
| Query.EQ(nameof(SomeConfiguration.Environment), Environment.Development.ToString())).FirstOrDefault(); | |
| // This doesn't | |
| SomeConfiguration configuration = someConfigurationCollection.Find( | |
| item => item.Environment == Environment.Development).FirstOrDefault(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment