Model view controller 从QueryMultiple结果中获取字符串值

Model view controller 从QueryMultiple结果中获取字符串值,model-view-controller,.net-core,Model View Controller,.net Core,在我的dotNetCore项目中,我有一个使用QueryMultiple返回多个结果集的查询 这是我的问题 var sql = @"SELECT CountryId as Id, CountryName as Name FROM country; SELECT CityId as Id, CityName as Name, CountryId FROM city; SELECT CitizenshipId as Id, CitizenshipNam

在我的
dotNetCore
项目中,我有一个使用
QueryMultiple
返回多个结果集的查询

这是我的问题

var sql = @"SELECT CountryId as Id, CountryName as Name FROM country;
            SELECT CityId as Id, CityName as Name, CountryId FROM city;
            SELECT CitizenshipId as Id, CitizenshipName as Name FROM citizenship;
            Select Count(user.UserId) as totalUserCount
                            FROM identityuser user;";
这就是我将其结果转化为变量的方式

 using (IDbConnection dbConnection = new DbManager().Connection)
            {
                dbConnection.Open();

                var grid = dbConnection.QueryMultiple(sql, new
                {
                });

                manageProfileView.countries = grid.Read<Country>().ToList();
                manageProfileView.cities = grid.Read<City>().ToList();
                manageProfileView.nationalities = grid.Read<CitizenShip>().ToList();
            }
使用(IDbConnection dbConnection=new DbManager().Connection)
{
dbConnection.Open();
var grid=dbConnection.QueryMultiple(sql,新
{
});
manageProfileView.countries=grid.Read().ToList();
manageProfileView.cities=grid.Read().ToList();
manageProfileView.nations=grid.Read().ToList();
}
现在我怎样才能得到这个查询的数据呢

选择Count(user.UserId)作为totalUserCount 来自identityuser用户

我试过这样的东西

var userCount=grid.Read().ToList()


但是它没有返回有效数据,有没有更好的方法从
网格
变量中获取简单计数。

我相信您只需要获取列表的相应计数,请尝试:

var userCount = grid.Read().ToList().Count;

userCount[0]将给出答案!若我的查询像
从usertable wehre userId=1中选择username
那个么我怎么能从网格中得到它的结果呢?