我有4个表tblEmployee,tblDepartment.tblCompany,tblNationality,第一个表是父表,所有三个表都带有引用ID' s。 follwoing是我的代码,用于获取员工数据详细信息
public class MainActivity extends Activity implements OnItemSelectedListener {
Spinner spinnerOsversions;
TextView selVersion;
private String[] state = { "Cupcake", "Donut", "Eclair", "Froyo",
"Gingerbread", "HoneyComb", "IceCream Sandwich", "Jellybean",
"kitkat" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println(state.length);
selVersion = (TextView) findViewById(R.id.selVersion);
spinnerOsversions = (Spinner) findViewById(R.id.osversions);
ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, state);
adapter_state.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerOsversions.setAdapter(adapter_state);
spinnerOsversions.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spinnerOsversions.setSelection(position);
String selState = (String) spinnerOsversions.getSelectedItem();
selVersion.setText("Selected Android OS:" + selState);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
我正在使用DataViewController.js这是一个脚本文件(AngularJS)
public JsonResult EmployeeRequests()
{
List<EmployeeRequests> CO = new List<EmployeeRequests>();
using (EmployeeContext dc = new EmployeeContext())
{
//var cust = dc.Customers.OrderBy(a => a.ContactName).ToList();
dc.Configuration.LazyLoadingEnabled = false;
var cust = dc.Employees.OrderBy(a => a.EmpName).ToList();
foreach (var i in cust)
{
var requests = dc.Requests.Where(a => a.EmployeeID.Equals(i.EmployeeID)).OrderBy(a => a.RequestDate).ToList();
CO.Add(new EmployeeRequests
{
Employee = i,
Requests = requests
});
}
}
return new JsonResult { Data = CO, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
DataView.cshtml如下图所示,我试图显示O.Company.CompName,O.Department.DeptName,O.Natioality.NatName,但它什么也没显示。
angular.module('MyApp') //extending angular module from first part
.controller('DataViewController', function ($scope, RequestService) { //explained about controller in Part2
$scope.Requests = [];
RequestService.GetRequests().then(function (d) {
$scope.Requests = d.data
});
})
.factory('RequestService', function ($http) { //explained about factory in Part2
var fac = {};
fac.GetRequests = function () {
return $http.get('/Data/EmployeeRequests');
}
return fac;
});