A nutrition definition. More...
Static Public Member Functions | |
static ICollection< Nutrient > | ListNutritionDefinitions () |
Returns a collection of NutritionalDefinitions in sorted order. | |
Properties | |
internal long | Id [get] |
string | Unit [get] |
Measuring unit. | |
string | TagName [get] |
Abbreviated name. | |
string | Description [get] |
Full name of the nutrition definition. | |
int | SortOrder [get] |
Sorder order for listing nutritional values. | |
static Nutrient | Calories [get] |
Gets total calories. | |
static Nutrient | Protein [get] |
Gets total protein. | |
static Nutrient | Carbohydrates [get] |
Gets total carbohydrates. | |
static Nutrient | Fat [get] |
Gets total fat. | |
Private Member Functions | |
Nutrient (NutritionDefinition nutRow) | |
Construction a Nutrient. | |
Static Private Member Functions | |
static internal Nutrient | CreateNutritionDefinition (long nutritionDefinitionRowId) |
Create a Nutrient for a NutritionDefinitionRowId. | |
static void | LoadDefinitions () |
Load NutritionDefinitions if not already loaded. | |
static Nutrient | FindNutrient (string tagName) |
Searches for a specific Nutrient by its TagName and returns it. | |
Private Attributes | |
NutritionDefinition | nutRow |
Static Private Attributes | |
static Dictionary< long, Nutrient > | definitions = null |
Lazily loaded dictionary of NutritionDefinitions, this is loaded by Nutrient.LoadDefinitions. |
A nutrition definition.
There only exists a few NutritionDefinitionRows in the database, but these are often used. Therefore this class is lazily caches a static list of all NutritionDefinitions and returns these using the factory methods. This approach used to minimize required database queries.
Also note that new NutritionDefinitionRows cannot be created, and existing ones cannot be changed.
Definition at line 18 of file Nutrient.cs.
Foodolini.BusinessLogic.Nutrient.Nutrient | ( | NutritionDefinition | nutRow | ) | [private] |
Construction a Nutrient.
Definition at line 25 of file Nutrient.cs.
static internal Nutrient Foodolini.BusinessLogic.Nutrient.CreateNutritionDefinition | ( | long | nutritionDefinitionRowId | ) | [static, private] |
Create a Nutrient for a NutritionDefinitionRowId.
This uses a static lazily loaded list to avoid querying the database.
Definition at line 85 of file Nutrient.cs.
static Nutrient Foodolini.BusinessLogic.Nutrient.FindNutrient | ( | string | tagName | ) | [static, private] |
Searches for a specific Nutrient by its TagName and returns it.
tagName |
Definition at line 151 of file Nutrient.cs.
static ICollection<Nutrient> Foodolini.BusinessLogic.Nutrient.ListNutritionDefinitions | ( | ) | [static] |
Returns a collection of NutritionalDefinitions in sorted order.
Definition at line 162 of file Nutrient.cs.
static void Foodolini.BusinessLogic.Nutrient.LoadDefinitions | ( | ) | [static, private] |
Load NutritionDefinitions if not already loaded.
Definition at line 101 of file Nutrient.cs.
Dictionary<long, Nutrient> Foodolini.BusinessLogic.Nutrient.definitions = null [static, private] |
Lazily loaded dictionary of NutritionDefinitions, this is loaded by Nutrient.LoadDefinitions.
Definition at line 96 of file Nutrient.cs.
Definition at line 20 of file Nutrient.cs.
Nutrient Foodolini.BusinessLogic.Nutrient.Calories [static, get] |
Nutrient Foodolini.BusinessLogic.Nutrient.Carbohydrates [static, get] |
string Foodolini.BusinessLogic.Nutrient.Description [get] |
Full name of the nutrition definition.
Definition at line 63 of file Nutrient.cs.
Nutrient Foodolini.BusinessLogic.Nutrient.Fat [static, get] |
internal long Foodolini.BusinessLogic.Nutrient.Id [get, private] |
Definition at line 30 of file Nutrient.cs.
Nutrient Foodolini.BusinessLogic.Nutrient.Protein [static, get] |
int Foodolini.BusinessLogic.Nutrient.SortOrder [get] |
Sorder order for listing nutritional values.
Definition at line 73 of file Nutrient.cs.
string Foodolini.BusinessLogic.Nutrient.TagName [get] |
Abbreviated name.
Definition at line 52 of file Nutrient.cs.
string Foodolini.BusinessLogic.Nutrient.Unit [get] |
Measuring unit.
Definition at line 41 of file Nutrient.cs.