我正在尝试转换 ffg:,
这个作品
IResultSEt rs = db.SELECT.COLUMNS(db.GetTable(data.ToString()).ColumnNames).FROM(data.ToString()).Execute();
进入这个,这是行不通的,
dynamic rs = db.SELECT.COLUMNS(db.GetTable(data.ToString()).ColumnNames);
rs = rs.FROM(data.ToString());
rs = rs.Execute();
它给了我一个错误,它找不到“COLUMNS”。
在调试时,似乎rs正在获取 SELECT 类中的所有返回方法和私有变量,它只是没有在运行时获取 SELECT 类中的 COLUMNS 之类的方法。这很奇怪,我以为它也能拿起方法,我做错了什么???
更新
db中 db的定义.SELECT.COLUMNS(db.GetTable(data.ToString()).ColumnNames); 是
public class Database
{
private Dictionary<string, ITable> _tables = new Dictionary<string, ITable>();
public ITable AddTable(string tableName, string[]columnNames, Type[] columnTypes)
{
ITable tbl = new Table(tableName);
tbl.SetColumns(columnNames, columnTypes);
_tables.Add(tableName.ToUpper(), tbl);
return tbl;
}
public ITable GetTable(string tableName)
{
return _tables[tableName.ToUpper()];
}
public ISELECT SELECT
{
get
{
ISELECT select = new SELECT(this);
return select;
}
}
public Dictionary<string,ITable> getTables()
{
return _tables;
}
}
db中SELECT的定义。SELECT .COLUMNS(db.GetTable(data.ToString()).ColumnNames); 这是我的SELECT类的接口;
public interface ISELECT
{
ISELECT TOP(Int32 N);
ISELECT DISTINCT { get; }
ISELECTCOLUMN COLUMN(string columnName);
ISELECTTABLECOLUMN COLUMN(string tableName, string columnName);
ISELECTCOLUMNS COLUMNS(params string[] columnNames);
ISELECTSUMCOLUMN SUM(string columnName);
ISELECTSUMCOLUMN SUM(string tableName, string columnName);
}
这就是问题所在,动态对象没有拾取接口中的方法,它拾取所有私有变量,它拾取的唯一方法是"DISTINCT"。
下面是 SELECT 类的部分定义,里面有很多代码,我就放一点;
internal class SELECT : ISELECT, ISELECTInternals
{
private Database _dw;
private bool _DISTINCT;
private Int32 _TOPN = -1;
private List<Int32> _JOINNumbers = new List<Int32>();
private string[] _selectJOINLHScolumnTableNames;
private string[] _selectJOINLHScolumnNames;
private string[] _selectJOINRHScolumnTableNames;
private string[] _selectJOINRHScolumnNames;
private string[] _selectcolumnTableNames;
private string[] _selectcolumnNames;
private string[] _selectcolumnAliases;
private object[] _selectcolumnLiterals;
private string[] _selectcolumnStringTemplates;
private AggregateTypes[] _selectcolumnAggregates;
private string[] _queryTableNames;
private string _SUMcolumnName;
private string _FROMTableName;
private List<string> _INNERJOINTableNames = new List<string>();
private List<string> _JOINTableNames = new List<string>();
private List<JoinTypes> _TableJoinTypes = new List<JoinTypes>();
private bool _takeANDFlag = true;
private List<string> _filterColumnTableNames = new List<string>();
private List<string> _filterColumnNames = new List<string>();
private List<object[]> _filterColumnValues = new List<object[]>();
private List<string> _GROUPBYcolumnTableNames = new List<string>();
private List<string> _GROUPBYcolumnNames = new List<string>();
等等