| Iam using asp.net webapi ,c# as i am new to expressmapper i have ado.net code which is returning list of reults.then how to map using expressmapper.searched so many sites but unfortunately no results found can u help in it |
- public class HomeController : ApiController
- {
- [HttpGet]
- [AllowAnonymous]
- public List
Newmethod() - {
- string connectionString =
- "server = sasd; database = das; uid = ds; pwd = Welcome@123; ";
- // Provide the query string with a parameter placeholder.
- string queryString =
- "SELECT distinct TOP 5 ISNULL(C.Name, 'Others') AS 'Company',A.Name AS 'Customers', O.Fee AS 'Amount' FROM ClientCursor.Opportunity AS O INNER JOIN Common.Company AS C ON C.Id = O.ServiceCompanyId INNER JOIN [ClientCursor].[Account] AS A ON A.Id = O.AccountId order by O.Fee DESC";
- // Create and open the connection in a using block. This
- // ensures that all resources will be closed and disposed
- // when the code exits.
- using (SqlConnection connection =
- new SqlConnection(connectionString))
- {
- // Create the Command and Parameter objects.
- SqlCommand command = new SqlCommand(queryString, connection);
- connection.Open();
- SqlDataAdapter da = new SqlDataAdapter(command);
- DataSet ds = new DataSet();
- da.Fill(ds, "newtable");
- Mapper.Register
().Flatten(); - yield return Mapper.Map
(ds); - }
- }
- }

Ananth GPosted Nov 4, 2016, 7:43 AM
Ananth GPosted Nov 4, 2016, 7:28 AM