SQL 인스턴스를 다르게하고 의사 교차 데이터베이스 조인, 데이터 복사 등을 실행할 수있는 컨텍스트를 인스턴스로 만들 수 있습니다. 컨텍스트간에 조인은 로컬에서 수행되므로 ToList(), ToArray() 등을 호출해야합니다. 결합하기 전에 각각의 데이터 소스를 사용하여 u 리를 개별적으로 실행합니다.즉, DB2 TABLE2의 20 행을 가진 DB1.TABLE1에서 10 개의 행을 "내부"로 조인하면 Linq가 조인을 수행하고 관련/교차하는 결과를 반환하기 전에 두 세트 (모두 30 행)를 로컬 시스템의 메모리로 가져와야합니다. 세트 (최대 20 개 행당 최대 행 수)
//EF6 context not selected in Linqpad Connection dropdown
var remoteContext = new YourContext();
remoteContext.Database.Connection.ConnectionString = "Server=[SERVER];Database="
+ "[DATABASE];Trusted_Connection=false;User ID=[SQLAUTHUSERID];Password="
+ "[SQLAUTHPASSWORD];Encrypt=True;";
remoteContext.Database.Connection.Open();
var DB1 = new Repository(remoteContext);
//EF6 connection to remote database
var remote = DB1.GetAll<Table1>()
.Where(x=>x.Id==123)
//note...depending on the default Linqpad connection you may get
//"EntityWrapperWithoutRelationships" results for
//results that include a complex type. you can use a Select() projection
//to specify only simple type columns
.Select(x=>new { x.Col1, x.Col1, etc... })
.Take(1)
.ToList().Dump(); // you must execute query by calling ToList(), ToArray(),
// etc before joining
//Linq-to-SQL default connection selected in Linqpad Connection dropdown
Table2.Where(x=>x.Id = 123)
.ToList() // you must execute query by calling ToList(), ToArray(),
// etc before joining
.Join(remote, a=> a.d, b=> (short?)b.Id, (a,b)=>new{b.Col1, b.Col2, a.Col1})
.Dump();
localContext.Database.Connection.Close();
localContext = null;
고마워요. 그게 분명 도움이 될거야. –