我正在使用 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;
}