首页 新闻 会员 周边

LINQ反编译过来的代码调整

0
悬赏园豆:20 [已解决问题] 解决于 2016-08-01 13:08

有人对LINQ熟悉吗,可以把这段代码调整一下吗?编译不了。

LogToFile.WriteProcedureLog("用 LINQ 語法結合 SQL_DataTable 以及 MDB_DataTable 來比對每一個資料表最後更新的時間, 找出 SQL 比 MDB 新的資料. --> 開始");
LogToFile.WriteProcedureLog("執行 LINQ 語法. --> 開始");
var enumerable2 = table.AsEnumerable().Join(table2.AsEnumerable(), delegate (DataRow table1) {
    return (string) table1["TableName"];
}, delegate (DataRow table2) {
    return (string) table2["TableName"];
}, delegate (DataRow table1, DataRow table2) {
    return new { table1 = table1, table2 = table2 };
}).Where(delegate (f_AnonymousType1<DataRow, DataRow> h_TransparentIdentifier1) {
    DateTime time;
    return (((bool) h_TransparentIdentifier1.table1["Enable"]) && (((time = (DateTime) h_TransparentIdentifier1.table1["LastTransaction"]) = (DateTime) h_TransparentIdentifier1.table2["LastTransaction"]).ToString("yyyy/MM/dd HH:mm:ss") != time.ToString("yyyy/MM/dd HH:mm:ss")));
}).Select(delegate (f_AnonymousType1<DataRow, DataRow> h_TransparentIdentifier1) {
    DateTime time = (DateTime) h_TransparentIdentifier1.table1["LastTransaction"];
    time = (DateTime) h_TransparentIdentifier1.table2["LastTransaction"];
    return new { SQLTableName = (string) h_TransparentIdentifier1.table1["TableName"], SQLDateTime = time.ToString("yyyy/MM/dd HH:mm:ss"), MDBDateTime = time.ToString("yyyy/MM/dd HH:mm:ss") };
});
二手 程序员的主页 二手 程序员 | 初学一级 | 园豆:159
提问于:2016-07-14 15:36
< >
分享
最佳答案
0

LogToFile.WriteProcedureLog("用 LINQ 語法結合 SQL_DataTable 以及 MDB_DataTable 來比對每一個資料表最後更新的時間, 找出 SQL 比 MDB 新的資料. --> 開始");
            LogToFile.WriteProcedureLog("執行 LINQ 語法. --> 開始");
            var enumerable2 = table.AsEnumerable().Join(table2.AsEnumerable(),
                t => (string)t["TableName"],
                t => (string)t["TableName"], (t1, t2) => {
                return new { table1 = t1, table2 = t2 };
            }).Where(h_TransparentIdentifier1 => {
                DateTime time = (DateTime)h_TransparentIdentifier1.table1["LastTransaction"];
                time = (DateTime)h_TransparentIdentifier1.table2["LastTransaction"];
                return (((bool)h_TransparentIdentifier1.table1["Enable"]) && ((time.ToString("yyyy/MM/dd HH:mm:ss")) != time.ToString("yyyy/MM/dd HH:mm:ss")));
            }).Select(h_TransparentIdentifier1 => {
                DateTime time = (DateTime)h_TransparentIdentifier1.table1["LastTransaction"];
                time = (DateTime)h_TransparentIdentifier1.table2["LastTransaction"];
                return new { SQLTableName = (string)h_TransparentIdentifier1.table1["TableName"], SQLDateTime = time.ToString("yyyy/MM/dd HH:mm:ss"), MDBDateTime = time.ToString("yyyy/MM/dd HH:mm:ss") };
            });

收获园豆:20
ArthurLi | 小虾三级 |园豆:686 | 2016-07-14 15:58
其他回答(1)
0

既然都LINQ了为什么还用 delegate

长蘑菇星人 | 园豆:1832 (小虾三级) | 2016-07-14 15:41

我也不知道,反编译过来的代码

支持(0) 反对(0) 二手 程序员 | 园豆:159 (初学一级) | 2016-07-14 15:44

有用到Anonymous Type吧

支持(0) 反对(0) 二手 程序员 | 园豆:159 (初学一级) | 2016-07-14 15:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册