如何在odata4j中加入两个表

时间:2016-12-05 09:24:56

标签: java android odata4j

我想在odata4j中从两个表EmployeeEducation中获取数据。公共列为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();


}

0 个答案:

没有答案