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"

我在 stak-overflow 上经历了许多类似的问题,但无法解决。需要一些关于代表的指导...

4

3 回答 3

1

很抱歉对我的问题的描述具有误导性。问题不是委托代码,而是我传递给实体框架查询的参数类型。由于 UserIdentity 是 Unique-identifier 类型,并且 pInfo 在 edmx 文件中有 StoreGeneratedPattern="none" 用于这种类型。我不得不在 edmx 文件中将 StoreGeneratedPattern 更改为身份类型,它工作正常。下面的帖子和上面的一些评论帮助我确定了这个问题。感谢大家的关心和宝贵的时间。 http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/

于 2013-04-28T20:41:41.090 回答
1

UserIdentity 是否为整数类型,如果不是,则需要UserIdentity.Id=currentuserid

于 2013-04-28T20:10:12.760 回答
1

您的 func 的参数与c => c.UserIdentity == currentuserid所需的不匹配,System.Func<Testproj.pInfo,int,bool>. 你也需要一个int论据。我假设您已经期望c成为Testproj.pInfo,因此您只需要为int. 基金的回报类型为bool。尝试:

.Where((c, i) => c.UserIdentity == currentuserid)
于 2013-04-28T19:27:25.303 回答