hi all:
I met a question that lets me to be disturbed today, although it can not produce by changing code line position, i want to know why it happens.
Steps:
1. I used Linq to get data from database, example code:
Quote:
var ret = (from c in getComment
join cr in context.GetTable<commentreply>() on c.ID equals cr.CommentID into crs
join oc in context.GetTable<ownercomment>() on c.ID equals oc.CommentID into ocs
from cr1 in crs.DefaultIfEmpty()
where c.EnumDataEntityStatus == EnumDataEntityStatus.Normal || IsForUserInfoSearch
from oc1 in ocs.DefaultIfEmpty()
where c.EnumDataEntityStatus == EnumDataEntityStatus.Normal || IsForUserInfoSearch
select new CommentSearchModel { comment = c, reply = cr1, ownerComment = oc1 });
2. there are two lines code, A and B, and , there are many "Linq where Sentence " lines code in front of A and B.
A is
ret = ret.Where(P => P.comment.OrderNumber.Contains(req.OrderNumber.Trim()));
B is
var excludeIDList = ret.Where(q => ((now - q.comment.CheckOutDate.Date).TotalDays > 30 && q.comment.EnumCommentStatus == 0 && q.comment.EnumOwnerCommentedStatus == 0) || q.comment.EnumCommentStatus == EnumCommentStatus.Expired).Select(x => x.comment.ID);
if (req.SpecificCondition == EnumSpecificQueryCondition.AllForMerchant)
ret = ret.Where(q => !excludeIDList .Contains(q.comment.ID));
B is executed,then will product a new object "
{System.Data.Linq.DataQuery<TuJia.Business.Customer.Contract.CommentSearchModel>}
" .
3. question:
If A is in the front B, as execute ret.toList(), exception will be produced.
If B is in the front A, as execute ret.toList(), exception will be produced.
4. Exception:
because, i use Chinese Operation System, my exceptions are Chinese, i will translate them into English, but perhaps be incorrect.
Exception:
Quote:
For method String.Contains, only parameters that can be evaluated on the client are supported
Chinese:
内容:对于方法 String.Contains,只支持可在客户端上求值的参数
5. At last, i hope that everybody can provide me with any information about it, i want to know the reason that produce exception.
Quote:
Thanks in advance!
What I have tried:
<pre lang="c#">