"query into complex object using dapper" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "query into complex object using dapper" answered properly. Developers are finding an appropriate answer about query into complex object using dapper related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like query into complex object using dapper. Enter your desired code related query in the search bar and get every piece of information about C# code related question on query into complex object using dapper.
query into complex object using dapper
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();
}
Source: dapper-tutorial.net
All those coders who are working on the C# based application and are stuck on query into complex object using dapper can get a collection of related answers to their query. Programmers need to enter their query on query into complex object using dapper related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about query into complex object using dapper for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of query into complex object using dapper while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "query into complex object using dapper". Visit this developer's friendly online web community, CodeProZone, and get your queries like query into complex object using dapper resolved professionally and stay updated to the latest C# updates.