Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取列的最大值_C#_Sqlite_Windows Phone 8 - Fatal编程技术网

C# 获取列的最大值

C# 获取列的最大值,c#,sqlite,windows-phone-8,C#,Sqlite,Windows Phone 8,我试图从表中的列中获取更多值。 我的桌子很简单: public class MensajeTablon { [PrimaryKey] public int id { get; set; } public int identificadorUsuario { get; set; } public string nombre { get; set; } public string mensaje { get; set; } public string

我试图从表中的列中获取更多值。 我的桌子很简单:

public class MensajeTablon
{
    [PrimaryKey]
    public int id { get; set; }
    public int identificadorUsuario { get; set; }
    public string nombre { get; set; }
    public string mensaje { get; set; }
    public string foto { get; set; }
    public DateTime fecha { get; set; }
    public int identificadorTablon { get; set; }
}
现在我的表中有两行,id为1,一行id为2。当我尝试查询时,它会返回一个id为0的对象。我不明白为什么。我的问题是:

var idMensaje = dbConn.Query<MensajeTablon>("select MAX(id) from MensajeTablon;");

我确信我有这两行,如果我阅读表select*from MensajeTablon,我会得到这两行。

我知道的唯一方法是创建一个类来镜像结果。所以

//表示所需结果的类 公共类MaxId { 公共int id{get;set;} } //现在,您还需要将其转换为id。。。。 var idMensaje=dbConn.Queryselect MAXid作为MensajeTablon的id; 现在idMensaje[0]。id是您的最大值


var existing是我查询的结果

查询结果如何?@CL.hmmm它似乎应该可以工作。我将尝试一下,看看它返回什么,如果它有效,则更新解决方案。@CL.它不起作用:它在现有中返回零,应该返回30,如上面的屏幕截图所示。