Niall Gallagher
asked on
Method is returning a query
I have no idea what I'm doing wrong here but I have an action
and this in my view
What am I doing wrong.
Thanks in advance
public ActionResult Edit(string id)
{
CWRepository CWA = new CWRepository();
var vm = new MerchantAgentViewModel()
{
merchantinfo = CWA.GetMerchantInfo(id),
merchantpercentages = CWA.GetMerchantPercentages(id),
getAgent1 = CWA.getAgentName(CWA.GetMerchantInfo(id).AGENT_ID.Value),
getAgent2 = CWA.getAgentName(CWA.GetMerchantInfo(id).AGENT_ID2.Value),
getAgent3 = CWA.getAgentName(CWA.GetMerchantInfo(id).AGENT_ID3.Value),
getAgent4 = CWA.getAgentName(CWA.GetMerchantInfo(id).AGENT_ID4.Value)
};
return View(vm);
}
I have this in my repository
public string getAgentName(int id)
{
using (CWA_MerchantEntities context = getDataContext())
{
var info = (from n in context.MERCHANT_AGENT
where n.Agent_ID == (id)
select n.Agent_F_Name + " " + n.Agent_L_Name
);
return info.ToString();
}
}
and this in my view
@Html.TextBoxFor(model => model.getAgent1, new { @class = "AgentName" })
The textboxes which should show the agents name, is filled with a query VS must be running.What am I doing wrong.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I apologise I went back and read your reply properly because I had posted what I had tried.
When I read it again I noticed the .first. and that was the right answer. Thank you
I was struggling with that for hours
When I read it again I noticed the .first. and that was the right answer. Thank you
I was struggling with that for hours
ASKER
Something so simple. Thank you
but then again everything is simple when you know the answer :)
but then again everything is simple when you know the answer :)
ASKER