使用greendao两个表中选择多个列 [英] Select multiple columns from two tables using greendao

查看:783
本文介绍了使用greendao两个表中选择多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表A和B,我想用greendao写下面的查询。

I have two tables A and B and I want to write the following query using greendao.

select a.*, b.* from A a, B b where a.a_id=b.a_id;

我迄今实现的:

Adao.queryRawCreate(" , B b where T.a_id=b.a_id");

但是,这将从A.只返回行,我需要从A和B的列。
我怎样才能做到这一点使用greendao?

But this will return only rows from A. I need the columns from A and B both. How can i achieve this using greendao?

推荐答案

Greendao不支持加入呢。

Greendao doesn't support joins yet.

即使它会:greendao是一个ORM框架。这意味着你的映射表行对象。随着一个ORM框架,你通常由对象遍历使用toMany和TOONE关系对象,你不要求多行映射到一个对象。

Even if it would: greendao is an ORM-framework. This means it maps your table-rows to object. With an ORM-framework you generally traverse from object to object using the toMany and toOne relations and you don't request multiple rows to be mapped to one object.

有关您的问题,这意味着你应该得到的你想要的实体。

For your problem this means you should get your desired entities of A.

如果您需要相应的B-实体您可以通过访问A.他们能够这样做,你必须指定A和B之间的toMany或TOONE关系(取决于您的数据模型)。​​

If you need the corresponding B-entities you can access them through A. To be able to do so you have to specify a toMany or toOne relation between A and B (depending on your datamodel).

这篇关于使用greendao两个表中选择多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆