Created
August 6, 2018 04:15
-
-
Save gsedubun/8147c9d1a599f04d2e6e1bf469f33582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Data.SqlClient; | |
using Dapper; | |
namespace tracking.Models | |
{ | |
public class AirportRepository{ | |
// change the user id and password accordingly. | |
private const string connstring = "Data Source=.\\sqlexpress;Initial Catalog=OSM_DB;user id=[id]; password=[password]"; | |
private SqlConnection Connection; | |
public AirportRepository() | |
{ | |
this.Connection = new SqlConnection(connstring); | |
} | |
public IEnumerable<Airport> Search(string name){ | |
name = "%"+name+"%"; | |
var data = Connection.Query<Airport>(@"select top 100 Name,Code,Latitude,Longitude,City,Country from airports | |
where name like @name", new {name}); | |
if(data!=null) | |
{ | |
return data; | |
} | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment