Last post Apr 11, 2017 02:45 PM by Rion Williams
Apr 11, 2017 01:18 PM|xfahadx|LINK
Is there a way to use ToString() in Lambda.
List<PostViewShoppingCart> scartList = (from s in MongoContext.ShoppingCart.AsQueryable()
join p in MongoContext.Products.AsQueryable() on
s.ProductId equals p._id
where s.UserName == uName
select new PostViewShoppingCart()
UserName = s.UserName,
SessionId = s.SessionId,
P_id = p._id.ToString(),
ProductDescription = p.ProductDescription,
ProductTitle = p.ProductTitle,
ImageURL = p.ImagePath,
QtyOrdered = s.QtyOrdered,
ProductSKU = p.ProductSku
p._id is type of ObhectId I want to convert it in to string as my model property P_id is type of string. I f I use ToString() as above I get an error . Is there any other way to achieve this?
Apr 11, 2017 02:45 PM|Rion Williams|LINK
You could try using the StringConvert() method, which SQL should be able to understand:
P_id = SqlFunctions.StringConvert((double)p._id),
This assumes that your ID is actually an integer (additionally, you could adjust your ShoppingCart object to better match your data and ignore this conversion entirely).