Question

I have a table in LINQ to SQL called "Cars" that contains "Car" objects.

Each Car has an EngineID and a ColourID.

I have created a new, local Car object just in memory (not yet committed to the database).

I already have an IEqualityComparer written which works well in conjunction with .Contains to tell me TRUE/FALSE if any cars "identical" to the one I've created already exist.

But it returns a bool..

How can I actually get WHICH cars are identical..?

E.g. I want like something like..

IQueryable<Car> IdenticalCar = db.Cars.Equals(MyCar).FirstOrDefault();
Was it helpful?

Solution

db.Cars.Where(c=>c.Equals(MyCar)).FirstOrDefault();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top