.NET:NpgsqlCommand到IQueryable

问题描述 投票:0回答:1

有没有办法从NpgsqlCommand创建IQueryable?

像这样的东西:

using (var connection = new NpgsqlConnection(_connectionString))
        {
            connection.Open();

            using (var cmd = new NpgsqlCommand("SELECT o.Id, o.Name FROM schema.blogs", connection))

            var blogsQueryable = cmd.Execute<IQueryable<BlogViewModel>>;
        }
postgresql asp.net-core .net-core npgsql
1个回答
0
投票

Npgsql本身只是一个ADO.NET提供程序,因此不会将行映射到您自己的对象。

您应该查看Entity Framework Core获取完整的O / RM,或者使用Dapper获得更轻的解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.