c# - LINQ to SQL Finding objects not listed in another list -
I am programming a data entry application for a vet and I have followed several different principles which MVC Nerd Dinner Application I'm 90% complete with my app, but I'm trying to clean up an annoying problem:
Currently when the user adds a pet for an invoice, I have a dropdown that is all Lists existing customers - whether they are not already on invoices, I want to include it only to include the customer's pet already on the invoice so that they are more than once Can not add pets.
After the idiot dinner tutorial application, I have a customer registrar CS file. The following questions:
// Finds a customer's pet list IQueryable & lt; Pet & gt; FindCustomerPets (int id) {Return from pets in DB Patt, where pet. Select Customer ID == ID Pet; }
If a pet is already on a journey, then it will record a travel details for it. So ... what I am trying to write is a query that can only be taken if there is no visit details for it. Here I am working with:
Public IQueryable & lt; Pet & gt; FindPetsNotOnVisit (int id) {visit visit = GetVisit (id); Miscellaneous pet = SearchCherpheets (visit.CustomerId); Var visitDetails = visit to db.VisitDetails, see visitDetail.VisitID == ID select visitDetail; // Where do I need to remove pet.PetID == visitDetail.PetID? } Not sure that I'm fine on your domain, but try to do something like this:
Public IQueryable & lt; Pet & gt; FindPetsNotOnVisit (int id) {visit visit = GetVisit (id); Miscellaneous pet = SearchCherpheets (visit.CustomerId); Var petIds = db.VisitDetails in the view, where visitDetail.VisitID == ID select visitDetail.PetID; Are changed. Where (P => Patio's. Canton (P. PETID)); }
You can end up with-without-so-pretty SQL statements. Using the SQL Server Profiler, find out how to go about it.
Comments
Post a Comment