-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataAccess.cs
More file actions
43 lines (32 loc) · 1.15 KB
/
DataAccess.cs
File metadata and controls
43 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Dapper;
using MySql.Data.MySqlClient;
namespace CityDBTest
{
public class DataAccess
{
public List<City> GetEntries(string[] terms)
{
using (MySqlConnection connection = new MySqlConnection(Helper.ConnectionVal("WorldCloudDB")))
{
try
{
var output = connection.Query<City>($"select * from {terms[0]}").ToList();
//var output = connection.Query<Grid>($"select * from {terms[0]} where {terms[1]} = '{terms[2]}'").ToList();
var output2 = connection.Query<>($"select * from {terms[0]}");
var col1 = output2.Read<string>().ToList();
var col2 = output2.Read<string>().ToList();
Console.WriteLine(col1[0] + " " + col2[0] + "\n" + col1[1] + " " + col2[1]);
return output;
}
catch(NullReferenceException)
{
return null;
}
}
}
}
}