Firstly, this is for a legacy application, so I cannot radically change any logic.
I have database with two tables that do not have any relationships. I asked if I change this, but was told I cannot.
These tables can be described as
Create Table T1
[doc_id] [int] NOT NULL, -- Primary Key
[customer_acc_no] [varchar](16) NULL,
[gcompany] [varchar](30) NULL,
....
extra fields
and table
Create Table T2
[UserURN] [int] NOT NULL, -- All three fields make up
[AccountNumber] [varchar](20) NOT NULL, -- the primary key
[Company] [varchar](50) NOT NULL,
....
extra fields
As you can see, not only are the field names different, but they have different lengths too.
I am using the Repository and UnitOfWork patterns. So far I have managed to code the following:
private IRepository<T1> _t1Repository;
private IRepository<T2> _t2Repository;
These are populated within the constructor.
Next I use the following code to configure get a queryable repository.
var retVal = _t1Repository.Queryable();
From this, I am trying to add the following join.
from q in T1
join w in T2
on new { X1 = q.gcompany, X2 = q.Customer_acc_no }
equals new { X1 = w.Company, X2 = w.AccountNumber }
I am thinking it would be along the lines of:
var query = T1.GroupJoin(T2,
c => c.gcompany,
o => o.Company,
(c, result) => new Result(c.doc_id, result))
.GroupJoin(T2,
c => c.Customer_acc_no,
o => o.AccountNumber ,
(c, result) => new Result(c.doc_id, result));
but i'm not sure as all attempts so far end in errors within visual studio.