public List<IB_VIEW_IU> Load(Guid? topicid, string title, string email, string type, string isgold, string astatus, string pstatus, int rows, int page, out int total)
{
var res = from idea in ideaDao.dbContext.IB_IDEA
join u in ideaUserDao.dbContext.IB_USER on idea.Creator equals u.ID into tmpU
from user in tmpU.DefaultIfEmpty()
where (string.IsNullOrEmpty(title) || idea.Title.Contains(title))
&& (string.IsNullOrEmpty(email) ? 0 == 0 : user.Email.ToString().Equals(email))
&& (string.IsNullOrEmpty(type) ? 0 == 0 : idea.IsTeam.ToString().Equals(type))
&& (string.IsNullOrEmpty(isgold) ? 0 == 0 : idea.IsGolden.ToString().Equals(isgold))
&& (string.IsNullOrEmpty(astatus) ? 0 == 0 : idea.AppState.ToString().Equals(astatus))
&& (string.IsNullOrEmpty(pstatus) ? 0 == 0
: pstatus == "0" ?idea.IsPut == 0 || idea.IsPut == 3
: pstatus == "1" ? idea.IsPut == 1
: pstatus == "2" ? idea.IsPut == 2
: pstatus == "3" ? idea.IsPut == 0
: pstatus == "4" ? idea.IsPut == 1 || idea.IsPut == 2 || idea.IsPut == 3
: pstatus == "5" ? idea.IsPut == 4: idea.IsPut == 3)
//&& ((topicid == Guid.Empty || string.IsNullOrEmpty(topicid.ToString())) ? 0 == 0 : idea.TopicID == topicid)
&& ((topicid == Guid.Empty || string.IsNullOrEmpty(topicid.ToString())) ? idea.TopicID == null : idea.TopicID == topicid)
orderby idea.CreateDate descending
select new IB_VIEW_IU()
{
ID = idea.ID,
IsTeam = idea.IsTeam,
Categorie = idea.Categorie,
Title = idea.Title,
Description = idea.Description,
Keyword = idea.Keyword,
Programme = idea.Programme,
IsGolden = idea.IsGolden,
Comment = idea.Comment,
Remark = idea.Remark,
Approver = idea.Approver,
AppState = idea.AppState,
GoldenApprover = idea.GoldenApprover,
Creator = idea.Creator,
CreateDate = idea.CreateDate,
Modifier = idea.Modifier,
ModifyDate = idea.ModifyDate,
TopicID = idea.TopicID,
UserID = user.UserID,
Mail = user.Email,
liketotal=idea.LikeTotal,
IsPut = idea.IsPut
};
var retList = res.ToList();
total = retList.Count();
return retList.Skip(rows * (page - 1)).Take(rows).ToList();
}
使用int.Parse()
方法即可转换:
var list = new List<View> {
new View { Id = 1,Name = "View001", TotalLike = "20"},
new View { Id = 2,Name = "View002", TotalLike = "50"},
new View { Id = 3,Name = "View003", TotalLike = "60"},
new View { Id = 4,Name = "View004", TotalLike = "80"},
};
var result = list.Select(x => new ViewDto
{
Id = x.Id,
Name = x.Name,
TotalLike = int.Parse(x.TotalLike)
});
Console.ReadKey();
class View
{
public int Id { get; set; }
public string Name { get; set; }
public string TotalLike { get; set; }
}
class ViewDto
{
public int Id { get; set; }
public string Name { get; set; }
public int TotalLike { get; set; }
}