QuestDb用导航查询报错! 返回
SqlSugar版本5.1.4.125-preview16用QuestDb时序数据库做导航查询时,代码如下,
var datas = Db.Queryable<StationHourData>().Where(i => i.Station.CityID == "460100").ToList();
报错:
Npgsql.PostgresException:“00000: Invalid table name or alias”
数据主表实体类定义:
[SugarIndex(null, nameof(StationId), OrderByType.Asc)]
public class StationHourData
{
[Key]
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 自动站ID
/// </summary>
[Display(Name = "自动站ID")]
[StringLength(10)]
[Required]
[SugarColumn(ColumnDataType = "symbol", Length = 10)]
public string StationId { get; set; }
[Navigate(NavigateType.OneToOne, nameof(StationId))]
public StationInfo Station { get; set; }
/// 观测时间
/// </summary>
[Display(Name = "观测时间")]
[TimeDbSplitField(DateType.Year)]
[Required]
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public DateTime ObservTime { get; set; }
/// <summary>
/// 过去1小时降水
/// </summary>
[Display(Name = "过去1小时降水")]
[SugarColumn(IsNullable = true)]
public double? R1H { get; set; }
}
外键表实体定义如下:
public class StationInfo
{
/// <summary>
/// 自动站编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 6)]
[Key]
[Required]
public string StationID { get; set; }
/// <summary>
/// 自动站名称
/// </summary>
[Required]
[SugarColumn(Length = 50)]
public string Name { get; set; }
/// <summary>
/// 经度
/// </summary>
[Required]
public double Lon { get; set; }
/// <summary>
/// 纬度
/// </summary>
[Required]
public double Lat { get; set; }
/// <summary>
/// 市县ID
/// </summary>
public string CityID { get; set; }
/// <summary>
/// 市县名称
/// </summary>
[SugarColumn(IsNullable = true)]
public string CityName { get; set; }
}
热忱回答(4)
-
fate sta VIP02023/12/4
var datas = db.Queryable<StationHourData>() .IncludeLeftJoin(it=>i.Station) .Where(it => i.Station.CityID == "460100").ToList();
这样写用联表,导航查询生成的子查询,questdb不支持,尽量用联处理
0 回复 -
trfftrff VIP02023/12/4
您好,按您说的这样联表查询试了,也是报一样的错误。
0 回复 -
fate sta VIP02023/12/4
@trfftrff:我用你的DEMO测试是可以的
0 回复 -
fate sta VIP02023/12/4
别名要一至
0 回复