C# 从实体类获取值

C# 从实体类获取值,c#,sql,asp.net,entity-framework,telerik,C#,Sql,Asp.net,Entity Framework,Telerik,我有一个具有最小值和最大值的方法硬代码我如何从实体模型类中提取值?我想查找最小值和最大值,以便它们不在代码中。我已经包含了我的代码和实体类以及sql表 谢谢 代码: protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { //Is it a GridDataItem if (e.Item is GridDataIte

我有一个具有最小值和最大值的方法硬代码我如何从实体模型类中提取值?我想查找最小值和最大值,以便它们不在代码中。我已经包含了我的代码和实体类以及sql表

谢谢

代码:

        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        //Is it a GridDataItem
        if (e.Item is GridDataItem)
        {
            //Get the instance of the right type
            GridDataItem dataBoundItem = e.Item as GridDataItem;

            //Check the formatting condition
            if (dataBoundItem["sample_hour"].Text == "4hr YP")
            {
                SetFormatting(dataBoundItem["ph"], 5.72f, 4.75f);
                SetFormatting(dataBoundItem["brix"], 17.35f, 22.36f);
                SetFormatting(dataBoundItem["temp"],89.08f, 90.97f);
                SetFormatting(dataBoundItem["bud"], 3.12f, 40.76f);
                SetFormatting(dataBoundItem["cell_count"], 41.24f, 177.70f);
                SetFormatting(dataBoundItem["viability"], 69.18f, 103.08f);
                SetFormatting(dataBoundItem["dp4"], 2.55f, 10.89f);
                SetFormatting(dataBoundItem["dp3"], 1.41f, 6.05f);
                SetFormatting(dataBoundItem["maltose"], 0.41f, 8.28f);
                SetFormatting(dataBoundItem["glucose"], -0.26f, 6.69f);
                SetFormatting(dataBoundItem["lactic_acid"], 0.01f, 0.12f);
                SetFormatting(dataBoundItem["glycerol"], 0.33f, 0.57f);
                SetFormatting(dataBoundItem["acetic_acid"], 0.07f, 0.17f);
                SetFormatting(dataBoundItem["ethanol"], .005f, 1.15f);
            }

        }
    }
    private void SetFormatting(TableCell cell, float minValue, float maxValue)
    {
        float value = float.Parse(cell.Text);

        if (value < minValue || value > maxValue)
        {
            cell.BackColor = Color.Yellow;
            cell.ForeColor = Color.Black;
            cell.Font.Bold = true;
        }
    }
    public partial class tbl_ferm_validation
{
    public int validation_id { get; set; }
    public string sample_type { get; set; }
    public Nullable<decimal> val_hi { get; set; }
    public Nullable<decimal> val_hihi { get; set; }
    public Nullable<decimal> val_lo { get; set; }
    public Nullable<decimal> val_lolo { get; set; }
}
1   ph  5.7200  NULL    4.7500  NULL
2   brix    17.3500 NULL    22.3600 NULL
3   temp    89.0800 NULL    90.9700 NULL
4   level   94.8100 NULL    88.1000 NULL
5   bud 3.1200  NULL    40.7600 NULL
6   cell count  41.2400 NULL    177.7000    NULL
7   viability   69.1800 NULL    103.0800    NULL
8   dp4 2.5500  NULL    10.8900 NULL
9   dp3 1.4100  NULL    6.0500  NULL
10  maltose 0.4100  NULL    8.2800  NULL
11  glucose -0.2600 NULL    6.6900  NULL
12  lactic acid 0.0100  NULL    0.1200  NULL
13  glycerol    0.3300  NULL    0.5700  NULL
14  acetic acid 0.0700  NULL    0.1700  NULL
15  ethanol 0.0050  NULL    1.1500  NULL