I have 3 objects and used EF to create tables as below. 1 to many between Country and State. 1 to many between State and City
Country {
List
}
State {
City
}
City {
}
How to I query using dapper so that I get all 3 in response
I have 3 objects and used EF to create tables as below. 1 to many between Country and State. 1 to many between State and City
Country {
List
}
State {
City
}
City {
}
How to I query using dapper so that I get all 3 in response
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Feb 11, 2023, 4:07 PM
Hi Dave,
Your class structure is like below:
Thanks
Naimish Makwana
Dave BellPosted Feb 11, 2023, 2:07 PM
Thanks Naimish. How to I define the Country Class? With below I do not get Cities list in response. I wish to have it under State.
public class Country
{
public int Id { get; set; }
public string Country_Name { get; set; }
public List States { get; set; }
}
Naimish MakwanaPosted Feb 11, 2023, 3:38 AM
Hello Dave,
Example SQL query that retrieves data for all countries, their states, and cities.
Map the results to your object model using Dapper:
Thanks
Naimish Makwana