1

我似乎只能找到如何从我的函数返回数组。这是我的模型:

[ActiveRecord("incident")]
public class Incident : ActiveRecordBase<Incident>
{
    public Incident() { }

    [PrimaryKey("id")]
    public int Id { get; set; }

    [Property("name")]
    public int Name { get; set; }
}

我目前正在使用 SimpleQuery,但是我不确定是否应该使用 HqlBasedQuery。这是我的调用函数:

 string query = @"select incident_id from Incident where incident_id = :incident_id";
 SimpleQuery<Incident> q = new SimpleQuery<Incident>(typeof(Incident), query);
 q.SetParameter("incident_id", _incidentId);
 q.SetQueryRange(1);

这可行,但我想要一个事件对象的通用列表。

谢谢你。

4

1 回答 1

1

一组 T ( T[]) 实现IList<T>,因此您已经获得了一个通用的对象列表:

string query = ...
IList<Incident> q = new SimpleQuery<Incident>(typeof(Incident), query).Execute();

如果要向该列表添加元素,请将其包装在另一个列表中:

IList<Incident> q = new List<Incident>(new SimpleQuery<Incident>(typeof(Incident), query).Execute());
于 2010-06-24T13:26:54.827 回答