0

我正在使用 petapoco。并加入 6 张桌子我得到了例外:不能在 2 张桌子之间进行分割点,如果有人对此有任何想法,请告诉我。

//数据访问

public static List<UserAccountsPOCO> GetFavouriteList(UserAccountsPOCO objUserAccountsPoco, int CurrPage, int PageSize)
        {
            var context = new PetaPoco.Database(Connection.connectionstring);
            SqlQuery =

            @"SELECT 
            UserAccount.UserId, UserAccount.Gender, UserAccount.DisplayName, UserAccount.CountryOfOrigin,
            UserAccount.CountryOfResidence, UserAccount.Tribe, UserAccount.Education, UserAccount.Occupation, 
            UserAccount.Height, UserAccount.BuildType, UserAccount.MartialStatus, UserAccount.ZipCode,
            UserAccount.AboutMe, UserAccount.BirthDate,UserAccount.MainFileId, UserAccount.CreatedDate, UserAccount.LastEditedDate,
            Qualification.QualificationName,MartialStatus.MartialStatus,BuildType.BuildTypeName, UserImages.ProfileImage,
            FavouriteList.UserId, FavouriteList.CreatedDate             

            FROM 
            ( SELECT 
                ROW_NUMBER() OVER (ORDER BY DisplayName) AS row, 
                UserAccount.UserId, UserAccount.Gender, UserAccount.DisplayName, UserAccount.CountryOfOrigin,
                UserAccount.CountryOfResidence, UserAccount.Tribe, UserAccount.Education, UserAccount.Occupation, 
                UserAccount.Height, UserAccount.BuildType, UserAccount.MartialStatus, UserAccount.ZipCode,
                UserAccount.AboutMe, UserAccount.BirthDate,UserAccount.MainFileId, UserAccount.CreatedDate, UserAccount.LastEditedDate FROM UserAccount
            ) AS UserAccount

            Left join FavouriteList on UserAccount.UserId = FavouriteList.FavouriteUserId
            Left join Qualification on UserAccount.Education = Qualification.QualificationId
            Left join MartialStatus on UserAccount.MartialStatus = MartialStatus.MartialStatusId
            Left join BuildType on UserAccount.BuildType = BuildType.BuildTypeId
            Left join UserImages on UserAccount.UserId = UserImages.UserId


            WHERE
             row > " + ((CurrPage - 1) * PageSize) + " and  row <= " + (CurrPage * PageSize) + "";

            List<UserAccountsPOCO> obUserAccountPoco = context.Query<UserAccountsPOCO>(new Type[] { typeof(UserAccountsPOCO), typeof(FavouriteListPOCO), typeof(QualificationPOCO), typeof(MartialStatusPOCO), typeof(BuildTypePOCO), typeof(UserImagesPOCO) }, null,

                SqlQuery,
                    new
                    {
                        @UserId = objUserAccountsPoco.UserId,
                        @CurrPage = CurrPage,
                        @PageSize = PageSize

                    }).ToList();

            return obUserAccountPoco;
        }
4

1 回答 1

2

列顺序必须与传递给 Query 方法的数组中指定的类型相匹配。例如。

根据您的专栏,它应该是:

1. UserAccountsPOCO
2. QualificationPOCO
3. MartialStatusPOCO
4. BuildTypePOCO
5. UserImagesPOCO
6. FavouriteListPOCO

但是你有:

1. UserAccountsPOCO 
2. FavouriteListPOCO 
3. QualificationPOCO  
4. MartialStatusPOCO
5. BuildTypePOCO
6. UserImagesPOCO
于 2013-09-11T10:52:01.267 回答