Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

using ToString() in Lambda

$
0
0

Hi,

Is there a way to use ToString() in Lambda. 

Query 

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

             }).ToList();

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?

Thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles