0

我正在编写的 Android 应用程序中使用 SQLite。该代码在查询中将两个参数连接为一个,但不会将其返回到持有类

我的查询代码如下所示

public List<BoyRecords> getBoyOrderedList(bool direction)
{
    string order = direction ? "LastName, Firstname" : "FirstName, LastName";
    string sql = "SELECT BoyID, FirstName || \' \' || LastName AS FullName FROM BoyRecords ORDER BY " + order;
    lock (this.dbLock)
    {
        using (SQLiteConnection sqlCon = new SQLiteConnection(this.DBPath))
        {
            sqlCon.Execute(Constants.DBClauseSyncOff);
            List<BoyRecords> br = sqlCon.Query<BoyRecords>(sql);
            return br;
        }
    }
}

BoyRecords 只是一个类

public class BoyRecords
{
    [PreserveProps(AllMembers=true)]
    public BoyRecords()
    {
    }

    public int BoyID
    { get; set; }

    [Ignore()]
    public Guid ReplicationID
    { get; set; }


    private string lastname;
    public string LastName
    {
        get { return string.IsNullOrEmpty(lastname) ? string.Empty : lastname;}
        set
        {
            lastname = value.Length > 30 ? value.Substring(0, 30).ToLower() : value.ToLower();
        }
    }

    private string firstname;
    public string FirstName
    {
        get { return string.IsNullOrEmpty(firstname) ? string.Empty : firstname;}
        set
        {
            firstname = value.Length > 30 ? value.Substring(0, 30).ToLower() : value.ToLower();
        }
    }

    private string FullName
    { get; set; }
}

(这只是类的一个子集,它实际上要大得多)。

虽然 BoyID 返回到类中,但 FullName 不是。这可能是因为我误解了 SQLite 手册,但是有没有办法将连接返回到 FullName 字段?

4

0 回答 0