I have three tables A, B, C. A having Id,Name,Address coulmns. B is the generic table having attributeID,aId, attributeName. where as c is the details table for B. with columns valueId, attributeId, aId Value.
Scenario is. suppose A is the Specific entity table (say Student). only containing the basic columns and values. where as B is there for additional columns for Entity student. (ex, student may have changed address, may have 3 mobile numbers)
Table: A
Aid Name Address1
std1 Student MG Street
std2 Employee Royal Street
Table : B
attributeId aID Value
att1 std1 Address2
att2 std1 ChangedAddress
att3 std1 Mobile1
att4 std1 Mobile2
Table :C
ValueId attributeId aID Value
val1 att1 std1 Stefen colony
val2 att2 std1 ChangedTo:Laurds
val3 att3 std1 87879797979798
val4 att4 std1 544559797979798
Note :Same for Employee
I want to build the query to get the all the valuefrom c for std1 with values in table A. But somehow db stucture is dynamic, in the sence the coulmns for the table A stored as values in table B, where as Values for B attributes stored in Table C. How to write Linq query for this?
You can simply join the records together like: