-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathParent-Child-Together.linq
33 lines (28 loc) · 1.01 KB
/
Parent-Child-Together.linq
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
<Query Kind="Program">
<NuGetReference>Insight.Database</NuGetReference>
<Namespace>Insight.Database</Namespace>
<Namespace>Insight.Database.Structure</Namespace>
<Namespace>System.Data.SqlClient</Namespace>
</Query>
void Main()
{
var connection = new SqlConnection(MyExtensions.SQLConnectionString);
SqlInsightDbProvider.RegisterProvider();
var response = connection.QuerySql(@"SELECT 1 ParentId, 'Jaxel' Name, 'Rojas' SecondName, 3 ChildId, 'Seba' ChildName, 'Rojas' SecondChildName UNION
SELECT 1 ParentId, 'Jaxel' Name, 'Rojas' SecondName, 4 ChildId, 'Aidan' ChildName, 'Rojas' SecondChildName", null,
Query.Returns(Together<Parent, Child>.Records));
response.Dump("Parent Child");
}
class Parent
{
public int ParentId { get; set; }
public string Name { get; set; }
public string SecondName { get; set; }
public IEnumerable<Child> Childs { get; set; }
}
class Child
{
public int ChildId { get; set; }
public string ChildName { get; set; }
public string SecondChildName { get; set; }
}