相关疑难解决方法(0)

Servicestack ORMLite查询多个

我想知道ORMLite是否有像Dapper这样的QueryMultiple解决方案.

我的用例是获取分页结果.

return new {
  Posts = conn.Select<Post>(q => q.Where(p => p.Tag == "Chris").Limit(20, 10))
  TotalPosts = conn.Count<Post>(q.Where(p => p.Tag == "Chris"))
};
Run Code Online (Sandbox Code Playgroud)

我还有一些其他情况,除了主查询之外我还在计算其他一些统计数据,我很想避免多次往返.

(可能不相关,但我正在使用PostgreSQL)

servicestack ormlite-servicestack

6
推荐指数
1
解决办法
1239
查看次数

OrmLite查询从2个连接表中的每一个中选择一些列

本评论之后,我如何进行连接两个或多个表的ServiceStack OrmLite查询并从每个表中返回一些列?

以OrmLite Does_only_populate_Select_fields_wildcard单元测试为例,我想做这样的事情:

public class DeptEmployee
{
    [PrimaryKey]
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    [References(typeof(Department2))]
    public int DepartmentId { get; set; }

    [Reference]
    public Department2 Department { get; set; }
}

public class Department2
{
    [PrimaryKey]
    public int Id { get; set; }
    public string Name { get; set; }
}

var q = db.From<DeptEmployee>()
    .Join<Department2>()
    .Select<DeptEmployee, Department2>((de, d2) => new[] …
Run Code Online (Sandbox Code Playgroud)

ormlite-servicestack

5
推荐指数
1
解决办法
3622
查看次数

标签 统计

ormlite-servicestack ×2

servicestack ×1