我在实体框架中有一个问题。
我有两张表:Customers
和Addresses
Customers
表包含有关客户的信息,Addresses
包含有关客户地址的信息。这两个表都由CustomerID
链接在一起。
如何获取居住在美国的所有Customers
个对象(来自Customers
)(来自Addresses
)?
有人可以帮忙吗?
答案 0 :(得分:1)
您可以像这样使用private void getFriendships(final String id) {
String tag_string_req = "req_friendships";
pDialog.setMessage("Sending Request for list of friends");
showDialog();
final String TAG = "List of friends request";
StringRequest strReq = new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Friendship request Response: " + response.toString());
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
Toast.makeText(getApplicationContext(), "Friends uploaded", Toast.LENGTH_LONG).show();
} else {
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "List of friends request Error: " + error.toString());
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
hideDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "friends");
params.put("sender", id);
return params;
}
};
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
:
.Where
这假定:
List<Customer> usaCustomers = dbcontext.Customers.Where(c => c.Address.Country == "USA");
属性