In my case I ended up on a number of stackoverflow pages.
Unit testing error, could not load file or assembly
To reproduce a bug I created a unit test with Rhino mocks. The testclass inherited from the testObject which had a virtual method. This virtual method returned a type defined in another assembly which wasn’t explicitly referenced by the unit test project. When building / discovering tests the following exception is thrown
Could not load file or assembly ‘x’ or one of its dependencies. Signature missing argument. (Exception from HRESULT: 0x801312E3)
By referencing the project that holds the type returned by the virtual method the exception was resolved and my repro unit test was ready.
How do I get a Distinct list to work with EF 4.x DBSet Context and the IEqualityComparer?
I ended up here when my MVC 4 with EF code first would give me an error. My controller needed to get the max price for each category. For this is tried to get the unique (distinct) categories and then query for the max price for each category. Turns out that can be done with the following:
var maxCategoryPrice = db.Products .GroupBy(x => x.CategoryId) .Select(x => new { CategoryId = x.Key, MaxPrice = x.Max(y => y.Price) });
Last and LastOrDefault not supported
Last one I figured out myself while I was correcting the previous linq statement, but there was a stackoverflow question. Just in case someone needed the answer I did the search…
LastOrDefault is not supported by EF, but can be replaced with OrderByReverse and FirstOrDefault.
// not supported var lastNewProduct = db.Products .OrderBy(x => x.CreateDate) .LastOrDefault(); // same result and supported var lastNewProduct = db.Products .OrderByDescending(x => x.CreateDate) .FirstOrDefault();