Click here to Skip to main content
15,891,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to pass a the name of Database View as a parameter to the web Api. According to the passed view name, It will return the json data to the client.

The approach that I am using is as below:

C#
public IEnumerable<object> Get(string ViewName)
{
    using (EnDBContext context = new EnDBContext())
    {
        switch (ViewName)
        {
            case "V_R_RESULT":

                return Mapper.Map<List<vmRResult>>(context.V_R_RESULT.ToList());


            case "V_REL_SHIP":

                return Mapper.Map<List<vmRelShip>>(context.V_REL_SHIP.ToList());
}

 return null;
}


Please let me know the right way to do it.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900