Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/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
Dart ToMany relation在link()处给出类型错误_Dart_Objectbox - Fatal编程技术网

Dart ToMany relation在link()处给出类型错误

Dart ToMany relation在link()处给出类型错误,dart,objectbox,Dart,Objectbox,我有一张桌子: @Entity() @JsonSerializable() 类DateTimeStruct{ @JsonKey(忽略:true) int id=0; DateTime=DateTime.now(); 字符串?标题; DateTimeStruct(); 工厂DateTimeStruct.fromJson(映射json)=>\uU$DateTimeStructFromJson(json); 映射到JSON()=>u$DateTimeStructToJson(此); } 及 @Jso

我有一张桌子:

@Entity()
@JsonSerializable()
类DateTimeStruct{
@JsonKey(忽略:true)
int id=0;
DateTime=DateTime.now();
字符串?标题;
DateTimeStruct();
工厂DateTimeStruct.fromJson(映射json)=>\uU$DateTimeStructFromJson(json);
映射到JSON()=>u$DateTimeStructToJson(此);
}

@JsonSerializable(explicitToJson:true)
@实体()
班级活动{
最后一次=汤姆尼();
}
当我尝试使用链接查询相关表时,如下所示:

Store.box().query().link(事件时间、,
DateTimeStruct_uu.time.greaterequal(DateTime.now().millissecondssinceepoch));
我明白了

The argument type 'QueryRelationMany<Event, DateTimeStruct>' can't be assigned to the parameter type 'QueryRelationProperty<Event, DateTimeStruct>'
无法将参数类型'QueryRelationMany'分配给参数类型'QueryRelationProperty'
错误消息

第二个问题:
DateTimeStruct\uuuu.time
解析为
QueryIntegerProperty time
,但它是一个DateTime。是否已在数据库中转换为整数

  • 给定的实体无法使用
    发布运行生成\u运行生成
    ,因为
    事件
    缺少
    id
  • 您正在对许多关系使用
    ——如果您想为每个
    事件
    存储多个
    DateTimeStruct
    ,您只需要确保您知道。如果每个事件只有一个时间是可以的(从概念上讲,这对我来说是正确的),请使用
    ToOne
  • 使用
    ToMany
    ,您需要使用
    .linkMany()
    而不是
    .link()
    ,这就是编译错误的来源
  • 是Dart
    DateTime
    对象存储为毫秒时间戳(除非您使用
    @Property(type:PropertyType.dateNano)注释
    另行指定)。您需要这样查询它们-您似乎这样做是正确的

  • 谢谢你,瓦因。请刷新文档,这里有一个ToMany with link()dart示例。