我想在odata4j中从两个表Employee
和Education
中获取数据。公共列为EmployeeId
。
我如何加入桌子?我使用它来获取数据但是它需要更多的时间。
private void DataListPosition() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
try {
ConnectionOData4j connectionClass = new ConnectionOData4j(context);
ODataConsumer consumer = connectionClass.getConnection();
for(OEntity entity : consumer.getEntities("Employee").execute()){
final String name=entity.getProperty("Name" , String.class).getValue();
((Activity) context).runOnUiThread(new Runnable() {
public void run() {
EmployeeName=name;
}
});
}
}catch (Exception e) {
final String strError=e.getMessage();
((Activity)context).runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(context, strError, Toast.LENGTH_LONG).show();
}
});
}
return null;
}
}.execute();
}
private void DataListEducation() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
try {
ConnectionOData4j connectionClass = new ConnectionOData4j(context);
ODataConsumer consumer = connectionClass.getConnection();
for(OEntity entity : consumer.getEntities("Education").execute()){
final String education=entity.getProperty("Education" , String.class).getValue();
((Activity) context).runOnUiThread(new Runnable() {
public void run() {
EmployeeEducation=education;
}
});
}
}catch (Exception e) {
final String strError=e.getMessage();
((Activity)context).runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(context, strError, Toast.LENGTH_LONG).show();
}
});
}
return null;
}
}.execute();
}