0
上堆棧溢出第一胎,我會盡力做到最好..ADO.NET LINQ的一個一對多選擇的用戶ID
下面,我從模型ADO.NET(MySQL數據庫)
http://img585.imageshack.us/img585/4533/screenshot20120519at143.png
// CHECK USER+PASS
rmEntities2 myDb = new rmEntities2();
var query = from c in myDb.users
where c.use_login == run.name
where c.use_password == run.pass
select c.use_id;
if (query.Count() == 0)
{
return "ERROR USER/PASSWORD";
}
else
{
// Linq insert DB
running newRun = new running();
newRun.run_start_time = new System.DateTime(1970, 1, 1, 0, 0, 0, 0)
.AddSeconds(Double.Parse(run.start));
newRun.run_end_time = new System.DateTime(1970, 1, 1, 0, 0, 0, 0)
.AddSeconds(Double.Parse(run.stop));
newRun.run_distance = (float)run.distance;
newRun.run_nbfootsteps = run.nbfootsteps;
newRun.run_vo2max = run.vo2Max;
foreach (int u in query)
{
newRun.user.use_id = u;
}
myDb.AddTorunnings(newRun);
myDb.SaveChanges();
return "RUNNING ADDED";
}
的問題是從這一行:
newRun.user.use_id = u;
我想成立run_use_id˚F ROM用戶在我的跑臺。
什麼是最好的方法?
它的工作,謝謝:) – user1405018