利用 c# linq 实现跨数据库的联合查询
时间:2021-07-01 10:21:17
帮助过:68人阅读
sql =
"select * from V_LoginLog where denglurq=@RQ";
DataTable dt = MsSqlHelper.ExecuteDataTable(ConnUeHis, sql,
new SqlParameter(
"@RQ", rq));
string sql1 =
"select * from app_getopdschdule where OPDDATE=:OPDDATE";
DataTable dt1 = OracleHelper.ExecuteDataTable(ConnStrLzHis, sql1,
new OracleParameter(
":OPDDATE", rq));
var res =
from m
in dt.AsEnumerable()
from s
in dt1.AsEnumerable()
where m.Field<
string>(
"LoginUser") == s.Field<
string>(
"DOCTORID") && m.Field<
string>(
"shangxiawbz") == Convert.ToString(s.Field<
decimal>(
"OPDTIMEID"))
select new {
DoctorName = s.Field<String>(
"DOCTORNAME"),
OpdTimeID = m.Field<String>(
"shangxiawbz"),
LoginTime = m.Field<DateTime>(
"denglusj"),
RoomName = s.Field<String>(
"ROOMNAME")
};
DataTable DtTemp =
new DataTable();
DtTemp.Columns.Add(
"DoctorName",
typeof(String));
DtTemp.Columns.Add(
"OpdTimeID",
typeof(String));
DtTemp.Columns.Add(
"RoomName",
typeof(String));
DtTemp.Columns.Add(
"LoginTime",
typeof(String));
foreach (
var obj
in res)
{
DtTemp.Rows.Add(obj.DoctorName, obj.OpdTimeID ==
"1" ?
"上午" :
"下午", obj.RoomName, obj.LoginTime.ToString(
"yyyy-MM-dd HH:mm:ss"));
}
return CommonHelper.Dtb2Json(DtAll);
利用 c# linq 实现跨数据库的联合查询
标签:login new oom convert string lin mss 联合查询 reac