回報和價值我創造了這個循環中的MVC:循環,在MVC
//this identify my user
string tmpUser = System.Web.HttpContext.Current.User.Identity.Name;
//this find user in database and compare his username with Identity name and returns userID
using (var dbUs = new userDbEntities())
{
var whoisloged = (from user in dbUs.UsersTables
where user.username == tmpUser
select user.userID).FirstOrDefault();
//get all destinations for user userid
var list1 = dbUs.CustomerTables.Where(m => m.UserId == whoisloged).Select(m => m.Customer);
var list2 = dbUs.CustomTypes.Where(m => list1.Contains(m.Id_NewCustomerType)).Select(m => m.CustomerType);
//this is LOOP that must return my values
foreach (var customer in list2)
{
string test = customer;
return new SolrQuery(test);
}
現在的問題是在我的LOOP的foreach ...爲什麼只返回第一個值?不管我在數據庫中有更多的數據。
我的結果sholud是這樣的:
例如用戶有人在應用程序中登錄。他/她在數據庫中保存了他/她的角色(代碼中的CustomerTable),例如, A,B和C,因此循環應該返回我是這樣的:
return new SolrQuery(A) + return new SolrQuery(B) + return new SolrQuery(C); // + is refer as AND
真的感謝您的幫助和任何想法...
我看到,我不需要「字符串測試=客戶」,我把回報新SoleQuery(客戶),但結果是一樣的,僅返回一個結果... –
但沒有返回句子... foreach返回正確的所有值。 –
你能顯示SolrQuery(test)的定義嗎? –