| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | 
							- using iBemsDataService.Model;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Web;
 
- namespace iBemsDataService.Controllers.Bems.Formula
 
- {
 
-     public class FormulaTableManager
 
-     {
 
-         private iBemsEntities db;
 
-         Dictionary<string, TableComparerValue[]> tables;
 
-         public FormulaTableManager()
 
-         {
 
-             db = new iBemsEntities();
 
-             tables = new Dictionary<string , TableComparerValue[]>();
 
-         }
 
-         public TableComparerValue[] GetTableValues( string functionName )
 
-         {
 
-             TableComparerValue[] values;
 
-             if( this.tables.ContainsKey( functionName ) )
 
-             {
 
-                 values = this.tables[functionName];
 
-             }
 
-             else
 
-             {
 
-                 var queryTable = from table in db.BemsFormulaTable
 
-                                  from value in db.BemsFormulaTableValue
 
-                                  where table.FunctionName == functionName &&
 
-                                     table.TableId == value.TableId
 
-                                  select new TableComparerValue {
 
-                                     XValue = value.XValue,
 
-                                     YValue = value.YValue
 
-                                  };
 
-                 if( queryTable.Any() == false )
 
-                 {
 
-                     return null;
 
-                 }
 
-                 values = queryTable.ToArray();
 
-             }
 
-             return values;
 
-         }
 
-         public class TableComparerValue : IComparable<TableComparerValue>
 
-         {
 
-             public double XValue { get; set; }
 
-             public double YValue { get; set; }
 
-             public int CompareTo( TableComparerValue other )
 
-             {
 
-                 var otherXValue = other.XValue;
 
-                 if( XValue < otherXValue )
 
-                 {
 
-                     return -1;
 
-                 }
 
-                 else if( XValue > otherXValue )
 
-                 {
 
-                     return 1;
 
-                 }
 
-                 return 0;   
 
-             }
 
-         };
 
-     }
 
- }
 
 
  |