2013-04-28 17 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

相关问题