我尝试使用连接选择来选择两个表头和明细。查询返回什么对象/列表值?我在flutter中使用了Floor ORM,但生成时不成功
这是我的班型和刀
flutter pub run build_runner build
[INFO] Running build...
[INFO] 1.0s elapsed, 0/2 actions completed.
[INFO] 2.1s elapsed, 0/2 actions completed.
[INFO] 8.4s elapsed, 0/2 actions completed.
[SEVERE] floor_generator:floor_generator on lib/database/Database.dart:
ERORR
Can not define return type
package:myapp_sfaf/database/dao/SalesOrderDao.dart:35:16
╷
35 │ Future<List> getListHeaderDetailByIdHso(String idHso);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
[INFO] Running build completed, took 8.8s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 59ms
[SEVERE] Failed after 8.8s
pub finished with exit code 1
class SalesOrderHd.dart
import 'package:floor/floor.dart';
import 'package:myapp_sfaf/database/entity/Customer.dart';
import 'package:myapp_sfaf/database/entity/Salesman.dart';
@Entity(tableName: 'thd_so',
indices: [Index(value: ['docCode'],unique: true)],
foreignKeys: [
ForeignKey(
childColumns: ['idCust'],
parentColumns: ['custId'],
entity: Customer,
onDelete: ForeignKeyAction.restrict
),
ForeignKey(
childColumns: ['idSals'],
parentColumns: ['idSalesman'],
entity: Salesman,
onDelete: ForeignKeyAction.restrict
)
]
)
class SalesOrderHd {
@primaryKey
final String idHso;
final String custCode;
final String custName;
final String address;
final String docCode;
SalesOrderHd(
this.idHso, this.custCode, this.custName, this.address, this.docCode
);
}
class SalesOrderDt.dart
import 'package:floor/floor.dart';
import 'package:myapp_sfaf/database/entity/ProductItem.dart';
import 'package:myapp_sfaf/database/entity/SalesOrderHd.dart';
@Entity(tableName: 'tdd_so')
class SalesOrderDt {
@primaryKey
final String id;
final String docCode;
final String itemCode;
final String itemName;
SalesOrderDt(
this.id,this.docCode, this.itemCode, this.itemName
);
}
SalesOrderDao.dart
@dao
abstract class SalesOrderDao {
@Query('SELECT hd.custName,hd.address, dt.itemCode, dt.itemName FROM thd_so hd
left join tdd_so dt WHERE hd.docCode = dt.docCode AND hd.idHso = :idHso')
Future<List> getListHeaderDetailByIdHso(String idHso);
}
不管是查询错误还是因为返回值不是我写的,我希望查询的返回值是一个列表对象模型,谢谢你的帮助,
1条答案
按热度按时间i7uq4tfw1#
问题解决了,我使用@DatabaseView。我创建了一个class .dart文件
在Dao文件中
用过的