在ServiceStack.OrmLite中选择数据子集

时间:2013-05-03 07:59:02

标签: ormlite-servicestack

有没有办法在ServiceStack.OrmLite中返回表的子集?
类似的东西:

public class MyStuff
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public byte[] Data { get; set; } // Some large blob, which is not desired in the list
}

var somestuff = db.Select<MyStuff>(x => new { Id = x.Id, Name = x.Name });

我真的希望避免手动的东西,比如“从某个地方选择blabla”......

2 个答案:

答案 0 :(得分:5)

为您的基本信息创建一个类并设置别名。

[Alias("MyStuff")]
public class MyBasicStuff
{
    public Guid Id { get;set; }
    public string Name { get; set; }
}

var basicStuff = db.Select<MyBasicStuff>();

答案 1 :(得分:5)

我有同样的问题。这是我做的:

public class MyStuff
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public byte[] Data { get; set; } 
}

var somestuff = Db.Select<MyStuff>(p => p.Select(x => new { x.Id, x.Name }));

对上面所做的唯一改变是对Db.Select做了。