我正在使用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;
}
答案 0 :(得分: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