I am working on an asp.net mvc web application, that connects to two different DB (I name them dbA & dbB). Currently I need to create a JSON object that contains values from different tables.
The two table are as follow:-
Table Technology from dbA
, have the following fields:-
>> dbAID , Tag , db2ID
While table Resource
from dbB have:-
>> Db2ID , Name
I have the following Action method:-
public ActionResult AutoComplete(string term)
{
var tech = dbA.Technology.Where(a=>a.Tag.StartWith(term));//select all technology that have their tags start with passed term
var db2IDList = tech.Select(a=>a.db2ID).ToArray();//create a list of db2ID
var resource = dbB.Resource.Where(db2IdList.Contains(a=>a.dbBID));//get the resource based on the db2IDList
JsonResult j = newJsonResult();
//here I want the json to contain the Technology.Tag + ResoruceNane, where the join is based on the db2Id stored insdie the technology table
}
So can anyone adivce what is the best way to construct my JSON object?
Thanks