我在视图上收到错误消息:
def room():
room_path=["1","2"]
user_choice = ""
print ("If you decide to ditch Todd and go to the campfire alone, enter 1")
print ("If you decide to drag Todd with you to the campfire, enter 2")
user_choice = input("your option number")
if user_choice == room_path [1]:
print ("yes")
elif user_choice == room_path [2]:
print ("no")
我的视图模型类:
The ObjectContext instance has been disposed. ....
Finnaly我有Ajax从控制器操作中获取
public class TruckLUOrderVD
{
public raTMS_TruckLoadingOrder TruckLoadingOrder { get; set; }
public List<raTMS_CompartmentLoadingOrder> TruckCompartment { get; set; }
public List<raTMS_Tank> TankTruck { get; set; }
public List<SelectListItem> LTank { get; set; }
public int LJetty { get; set; }
public List<raTMS_ShipAgent> Agent { get; set; }
public List<raTMS_Ship> Ship { get; set; }
public List<string> service = new List<string> { "Loading", "Unloading"};
public List<SelectListItem> modeList { get; set; }
public List<Boolean> compartmentEnabled { get; set; }
public string shiptype { get; set; }
public Boolean multiolder { get; set; }
public string maxcmp { get; set; }
public string serviceval { get; set; }
public string statusname { get; set; }
public string serviceAutoNumber { get; set; }
public string[] productnm { get; set; }
}
我尝试过一些像LazyLoading和ProxyCreationEnabled这样的实体配置。
public JsonResult Getdetail(int id)
{
raTMS_Tank TANK = new raTMS_Tank();
raTMS_Ship Ship = new raTMS_Ship();
raTMS_ShipAgent agent = new raTMS_ShipAgent();
raTMS_ShipOrder order = new raTMS_ShipOrder();
raTMS_ShipTankUnloadingOrder stank = new raTMS_ShipTankUnloadingOrder();
raTMS_TruckLoadingOrder SR = new raTMS_TruckLoadingOrder();
List<raTMS_TruckLoadingOrder> ListA = new List<raTMS_TruckLoadingOrder>();
List<raTMS_CompartmentLoadingOrder> ListB = new List<raTMS_CompartmentLoadingOrder>();
List<raTMS_ShipTankUnloadingOrder> ListC = new List<raTMS_ShipTankUnloadingOrder>();
TruckLUOrderVD vd = new TruckLUOrderVD();
using (raTMSEntities2 db = new raTMSEntities2())
{
var c = db.raTMS_CompartmentLoadingOrder.Where(x => x.TruckLoadingOrderFK == id).ToList();
SR = db.raTMS_TruckLoadingOrder.Where(x => x.PriKey == id).FirstOrDefault();
for (int i = 0; i < SR.raTMS_Truck.CompartmentNumber; i++)
{
var c1 = c.Where(x => x.CompartmentNumber == i + 1).FirstOrDefault();
if (c1 != null)
{
ListB.Add(c1);
ListB[i].OrderPrikey = c1.OrderFK;
ListB[i].FQTransact = c1.raTMS_Order.TansactQty.GetValueOrDefault();
ListB[i].AQReserved = c1.raTMS_Order.ReservedQty.GetValueOrDefault();
}
else
{
ListB.Add(new raTMS_CompartmentLoadingOrder());
}
}
raTMS_Status stat = new raTMS_Status();
vd.statusname = stat.getStatusName(SR.Status.Value);
vd.TruckLoadingOrder = SR;
vd.TruckCompartment = ListB;
return Json(new { vd = vd }, JsonRequestBehavior.AllowGet);
}
}
我无法通过Ajax获取数据。它可以通过不使用Json的视图模型类成功返回,我需要在不重新加载页面的情况下运行此操作。我收到错误,如上面的错误消息。我的Linq有什么错误吗?
谢谢