query into complex object using dapper
C#
public class Customer {
public int Id { get; set; }
public string Name { get; set; }
public int AddressId { get; set; }
public int ContactId { get; set; }
public Address Address { get; set; }
public Contact Contact { get; set; }
}
public class Address {
public int Id { get; set; }
public string Address1 {get;set;}
public string Address2 {get;set;}
public string City {get;set;}
public string State {get;set;}
public int ZipCode {get;set;}
public IEnumerable<Customer> Customer {get;set;}
}
public class Contact {
public int Id { get; set; }
public string Name { get; set; }
public IEnumerable<Customer> Customer {get;set;}
}
using (var conn = GetOpenConnection())
{
var query = _contextDapper
.Query<Customer, Address, Contact, Customer>($@"
SELECT c.Id, c.Name,
c.AddressId, a.Id, a.Address1, a.Address2, a.City, a.State, a.ZipCode,
c.ContactId, ct.Id, ct.Name
FROM Customer c
INNER JOIN Address a ON a.Id = c.AddressId
INNER JOIN Contact ct ON ct.Id = c.ContactId",
(c, a, ct) =>
{
c.LogType = a;
c.Contact = ct;
return c;
}, splitOn: "AddressId, ContactId")
.AsQueryable();
return query.ToList();
}
Also in C#:
- Title
- unity random float
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- unity 2d platformer movement script c#
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- array syntax c#
- Category
- C#
- Title
- error CS0542
- Category
- C#
- Title
- c# make request to rest api
- Category
- C#
- Title
- how to delay something in c# unity
- Category
- C#
- Title
- iterate through dictionary c#
- Category
- C#
- Title
- initialize enum with another enum c#
- Category
- C#
- Title
- how to add a componet to a gameobject throgh code unity
- Category
- C#
- Title
- c# how to exit program
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- unity fps counter
- Category
- C#
- Title
- appsettings in console application c#
- Category
- C#
- Title
- c# find element by condition
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- unity set object scale
- Category
- C#
- Title
- c# summary tag
- Category
- C#
- Title
- c# getasync response
- Category
- C#
- Title
- what does thismean incsharp public static void Main
- Category
- C#
- Title
- c# list append
- Category
- C#
- Title
- c# read file stream
- Category
- C#
- Title
- public enum c#
- Category
- C#
- Title
- unity making homing rocket
- Category
- C#
- Title
- c# null conditional operator if statement
- Category
- C#
- Title
- c# change label forecolor code
- Category
- C#
- Title
- console application in c# ms crm
- Category
- C#
- Title
- datetitime contrusctor c#
- Category
- C#
- Title
- unity transformer double en float
- Category
- C#
- Title
- vb.net drag window without titlebar
- Category
- C#
- Title
- prefab gets character transform
- Category
- C#
- Title
- c# loop
- Category
- C#
- Title
- c# region tag
- Category
- C#
- Title
- unity jump
- Category
- C#
- Title
- c# random string
- Category
- C#
- Title
- how to chagne rotation in unity
- Category
- C#
- Title
- c# check if string is in array
- Category
- C#
- Title
- c# getter setter
- Category
- C#
- Title
- override Microsoft.AspNetCore.Authorization.AuthorizeAttribute
- Category
- C#
- Title
- c# clear console read chache
- Category
- C#
- Title
- c# get executable path
- Category
- C#
- Title
- unity ui not seen
- Category
- C#
- Title
- how to trigger event when a com device is connected in c#
- Category
- C#
- Title
- unity cast float to int
- Category
- C#
- Title
- write string multiple times c#
- Category
- C#
- Title
- automapper c# initialize error
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- c# print
- Category
- C#
- Title
- open udp socket c#
- Category
- C#
- Title
- convert comma separated string to array c#
- Category
- C#
- Title
- C# enum
- Category
- C#
- Title
- application variable in asp.net core
- Category
- C#
- Title
- razor preview
- Category
- C#
- Title
- c# string remove special characters
- Category
- C#
- Title
- isInstanceOf nunit
- Category
- C#
- Title
- binding c#
- Category
- C#
- Title
- weakreference tryget c#
- Category
- C#
- Title
- class selector to property in asp net core dropdown
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- wpf get name of clicked element
- Category
- C#
- Title
- generate a dropdown list from array data using razor .net mvc
- Category
- C#
- Title
- how to locate a specific element in a list c#
- Category
- C#
- Title
- c# windows grab screenshot
- Category
- C#
- Title
- how get data from json in c#
- Category
- C#
- Title
- wpf use enum description
- Category
- C#
- Title
- cc# sort list with list if ids
- Category
- C#
- Title
- unity clamp rotation
- Category
- C#
- Title
- add row count devepxress report
- Category
- C#
- Title
- optional parameter get request c#
- Category
- C#
- Title
- orderby make sunday last day c#
- Category
- C#
- Title
- sum the digits in c#
- Category
- C#
- Title
- how to access the dictionary from another script in unity
- Category
- C#
- Title
- c# input
- Category
- C#
- Title
- snippet to create constructor in asp.net c#
- Category
- C#
- Title
- asp.net textarea disable resize
- Category
- C#
- Title
- c# declare an int list
- Category
- C#
- Title
- c# fold list
- Category
- C#
- Title
- c# multiple catch exceptions
- Category
- C#
- Title
- animator hash in unity
- Category
- C#
- Title
- unity invoke
- Category
- C#
- Title
- reference to gameobject in different scene unity
- Category
- C#
- Title
- c# input integer
- Category
- C#
- Title
- c# retrieve files in folder
- Category
- C#
- Title
- open zip file in c#
- Category
- C#
- Title
- dynamically add rows to datagridview c#
- Category
- C#
- Title
- how to get odd saturday in a month in c#
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
- Category
- C#
- Title
- disable a component unity
- Category
- C#
- Title
- c# random number between 0 and 1
- Category
- C#
- Title
- itext7 pdfwriter outputstream c#
- Category
- C#
- Title
- what is c# used for
- Category
- C#
- Title
- No context type was found in the assembly
- Category
- C#
- Title
- string to enum c#
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- change textbox location C#
- Category
- C#
- Title
- remove all array elements c#
- Category
- C#
- Title
- how to make % posibility to spawn an object C# in unity
- Category
- C#
- Title
- make camera follow character unity 2020
- Category
- C#