Questions tagged [linq-method-syntax]

38 questions
0
votes
1 answer

How to return custom objects using Except

I'm using ASP.NET MVC, C# and SQL Server. I want to get a list of cars that are available for rent within a certain date, ie. not already rented out. What I got now is something like taking all the cars from the cars table, except the ones that…
CAR1980
  • 33
  • 4
0
votes
3 answers

Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Linq.IQueryable'

This query is being compiled without errors: var _entityList = context.customer .Join(context.applications, cust => cust.cust_id, app => app.cust_id, (cust, app) => new {…
Khadim Ali
  • 2,406
  • 2
  • 26
  • 56
0
votes
1 answer

The cast to value type 'Decimal' failed because the materialized value is null

I have the following code : public ViewResult Stock(Guid id) { // Get the product form the database var product = productRepository.GetById(id); var viewModel = new ProductStockViewModel() { …
Marc
  • 1,831
  • 4
  • 13
  • 26
0
votes
2 answers

Entity Framework Simple Filter by NavigationProperty using LINQ Methods

I am learning EF and LINQ to EF. We are using LINQ Methods and not LINQ Expressions. I am trying to do a very simple query from my 2 entities. NavigationGroup is a one to many relation to NavigationGroupLocation. The Navigation Property in…
Jared
  • 2,184
  • 8
  • 23
  • 37
-1
votes
2 answers

Linq query with method syntax needed for two lists with type List

var fullMessagesList = new List(){ "This is Apple", "This is mango", "This is a Lemon", "This is a Orange" }; var partialMessagesList = new List(){ "Apple", "mango", }; I need a linq query with method syntax with returns "This is a…
Mudassir Hussain
  • 514
  • 4
  • 16
-1
votes
2 answers

GroupBy with Linq to entities query

I have following classes: public class OrderItem { public int Id { get; set; } public ICollection NominalRoutings{ get; set; } } public class NominalRouting { public int Id { get; set; } public DateTime PlanedDate…
Masoud
  • 7,580
  • 9
  • 51
  • 108
-3
votes
1 answer

linq convert query syntax to method syntax

How can I convert this query syntax to method syntax in linq: return (from x in db.Table1 join y in db.Table1 on x.ID equals y.ID - 1 where Convert.ToInt32(y.ID) >= Convert.ToInt32(x.ID) …
Laziale
  • 7,259
  • 39
  • 131
  • 229
-3
votes
1 answer

Do can I convert this query syntax linq expression to method syntax?

I've written this code to join two tables together from sql server, now I want to write this as in method syntax. How can I rewrite this code? LinqToLoginDataContext lnqdore = new LinqToLoginDataContext(); var f = (from k in lnqdore.Table_Years …
1 2
3