gt5193
gt5193

Reputation: 19

Entity Framework 6.1.3

I have a project that looks up distinct orders from the database. It then creates a string of CustomerNumbers from a field in the returned orders. Then it filters the orders based on the CustomerNumbers. The issue is it only ever returns 2 customers when there should be 10. I did return a count of all customers & that also only returns 2 customers. There are a total of 667K+ customers in the database. I tried uninstalling the EF nuget package & reinstalling. I checked to make sure the repositories I have setup aren't filtering anything in anyway. I'm stuck & under the gun right. Any help would be great. Also any refactoring suggestions or EF changes are welcome too. Thanks!

var count = dbCustomer.Records.Count();

var orders = dbOrders.Records.ToList();
data.Orders = orders;

var orderCustomerNumbers = data.Orders.Select(o => oMeta15).Distinct().ToList();
var orderNumbers = data.Orders.Select(o => o.OrderNumber.ToLower()).ToList();

data.Customers = dbCustomer.Records.Where(c => orderCustomerNumbers.Contains(c.CustomerNumber)).To.List();
data.Payments = dbPayment.Records.Where(p => orderCustomerNumbers.Contains(p.OrderNumber.ToLower())).ToList();
data.Products = dbProducts.Records.Tolist();

Upvotes: 0

Views: 118

Answers (1)

gt5193
gt5193

Reputation: 19

Sorry for not getting more details out, but I did fix the issue. Originally I had issues getting the data into the database using the app(EF). To get around the issue and keep moving forward I used SSMS to import the data. Since I didn't use the app(EF), to import the data the Discriminator column was never filled in with data. Therefore the only two rows that were being returned were the rows with the correct value in the Discriminator column. After running a quick SQL statement to update all the rows with the correct Discriminator value everything is working fine now.

Upvotes: 1

Related Questions