2013-04-28 54 views
1
MembershipUser userobj = Membership.GetUser(); 
     Guid currentuserid = (Guid)userobj.ProviderUserKey; 
     List<pInfo> pobj = new List<pInfo>(); 
     pobj = (from pid in db.pInfoes.Where(c => c.UserIdentity == currentuserid) 
       orderby pid.pId descending 
       select pid).ToList(); 
     return View(pobj); 


    (c => c.UserIdentity == currentuserid) : Error -- Delegate "System.Func<Testproj.pInfo,int,bool> does not take 1 argument" 

我已經經歷了許多類似的樁溢出問題,但無法解決它。需要一些代表的指導...代表「System.Func <Testproj.pInfo,int,bool>不帶1個參數」

回答

1

對不起,誤導性說明我的問題。該問題不委託代碼,但我是路過的參數類型到實體框架查詢。由於UserIdentity的類型是Unique-identifier,並且pInfo在此類型的edmx文件中有StoreGeneratedPattern =「none」。 我必須將StoreGeneratedPattern更改爲edmx文件中的標識類型,並且它工作正常。 以下文章和上面的一些評論幫助我確定了這個問題。 感謝您的關心和寶貴的時間。 http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/

1

您的功能的參數c => c.UserIdentity == currentuserid不符合要求,System.Func<Testproj.pInfo,int,bool>。你也需要一個int參數。我假設你已經期待cTestproj.pInfo,所以你只需要爲int添加一個參數。該基金的回報類型爲bool。嘗試:

.Where((c, i) => c.UserIdentity == currentuserid) 
+0

嗯現在它說不需要2個參數... – Scorpio 2013-04-28 19:31:46

+0

現在有什麼錯誤? – 2013-04-28 19:32:46

+0

代表「System.Func 不帶2個參數」 – Scorpio 2013-04-28 19:33:46

1

的UserIdentity是一個整數類型,如果沒有,則需要UserIdentity.Id=currentuserid

相關問題