开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 1975|回复: 0

Structure of Classes in a Scaffolded Application for WPF

[复制链接]

0

精华

596

贡献

57

赞扬

赞助者组

Rank: 14Rank: 14Rank: 14Rank: 14

帖子
27
软币
230
在线时间
21 小时
注册时间
2013-7-18
发表于 2017-11-3 09:35:00 | 显示全部楼层 |阅读模式
/// <summary>
    /// A UserContextUnitOfWork instance that represents the run-time implementation of the IUserContextUnitOfWork interface.
    /// </summary>
    public class UserContextUnitOfWork : DbUnitOfWork<UserContext>, IUserContextUnitOfWork
    {

        public UserContextUnitOfWork(Func<UserContext> contextFactory)
            : base(contextFactory)
        {
        }

        IRepository<User, int> IUserContextUnitOfWork.Users
        {
            get { return GetRepository(x => x.Set<User>(), (User x) => x.Id); }
        }

        IRepository<UserInfo, int> IUserContextUnitOfWork.UserInfos
        {
            get { return GetRepository(x => x.Set<UserInfo>(), (UserInfo x) => x.Id); }
        }

        IRepository<Role, int> IUserContextUnitOfWork.Roles
        {
            get { return GetRepository(x => x.Set<Role>(), (Role x) => x.Id); }
        }

        IRepository<Retry, int> IUserContextUnitOfWork.Retries
        {
            get { return GetRepository(x => x.Set<Retry>(), (Retry x) => x.Id); }
        }

        IRepository<Category, int> IUserContextUnitOfWork.Categories
        {
            get { return GetRepository(x => x.Set<Category>(), (Category x) => new { x.CatListNum, x.RoleId }); }
        }
    }
在搭建Scaffolded Application时,unitofwork的基础类里实体Category中我没有ID主键,我使用(new { x.CatListNum, x.RoleId)做联合主键,但VS报错提示GetRepository(x => x.Set<Category>(), (Category x) => new { x.CatListNum, x.RoleId })不能隐式转换为IRepository<Category, int>的类型,诸位有能解决这个问题的不?

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-5-18 17:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表