有人对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") }; });
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") };
});
既然都LINQ了为什么还用 delegate
我也不知道,反编译过来的代码
有用到Anonymous Type吧