Exemple #1
0
 /// <summary>
 /// 按主数据索引,获取该查询位置
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="mainDataIndex"></param>
 /// <param name="db"></param>
 /// <returns></returns>
 public static Location GetLocation(string tableName, int mainDataIndex, DataBase db)
 {
     var table = _Table.Find(b => b.TableName == tableName && b.DataBaseName == db.Name);
     if (table == null)//找哪个表
     {
         throw new Exception(string.Format("找不到指定的表{1}在库{0}", db.Name, tableName));
     }
     TablePart part;
     //找分表
     if (table.IsMainTable)//如果只是主数据表,只按一个找就行了
     {
         part = _TablePart.Find(b => b.TableName == tableName && b.DataBaseName == db.Name);
     }
     else//其它表,按分表找
     {
         part = _TablePart.Find(b => mainDataIndex >= b.MainDataStartIndex && mainDataIndex <= b.MainDataEndIndex && b.TableName == tableName && b.DataBaseName == db.Name);
     }
     if (part == null)
     {
         throw new Exception(string.Format("找不到指定的表{1}在库{0}", db.Name, tableName));
     }
     return new Location() { DataBase = db, TablePart = part };
 }
Exemple #2
0
 public static List<TablePart> GetAllTable(DataBase db,string tableName)
 {
     return _TablePart.FindAll(b => b.DataBaseName == db.Name && b.TableName == tableName);
 }