last day (15 days later) » 

7:18 AM
Hi, Tom!
 
Tom
7:50 AM
Hi Johny
let me know when you are ready
 
8:31 AM
Hello, I am here)))
I'm just preparing the answer for your second question )))
 
Tom
oh ok
Thank you so much
 
To get `PersonNotes` by *one* `PersonID`:

IQueryable<PersonNote> GetPersonNotesSingleId(int ID) =>
context.PersonNotes.Where(p => p.PersonId == ID);

To get `PersonNotes` by *multiple* `PersonID`s:

IQueryable<PersonNote> GetPersonNotesMultipleId(IEnumerable<int> IDs) =>
context.PersonNotes.Where(p => IDs.Contains(p.PersonId));

The last query will generate `IN` T-SQL clause:

```var notes = GetPersonNotesMultipleId(new[] { 1, 2, 3 });
 
Tom
Well in my case it will always be the first scenario but thanks for showing both. Let me go with the first one and see. I have also posted one last question with an issue that i am facing around this area. Could you please take a look at it as well. As I am unable to compile without solving that issue. If that issue gets solved , I would be able to validate this solution that you have proposed
-1
Q: Entity Framework Core 3 : Type must match overridden member

TomI have the following two dbcontexts in my Entity Framework Core solution. The OrganisationContext derives from SagitarriContext. I am overiding the base property DbSet<Person> Person. I am getting the following error in the derived class: Error CS1715 'OrganisationContext.Person': type mus...

 
OK!
 
Tom
8:49 AM
Can i also write the your first query this way like a method returning
public IEnumerable<PersonNote> GetPersonNotes(int personId)
{
var PersonNotes1 = _context.PersonNotes.Where(p => _context.PersonNotes.Where(p => p.PersonId == personId).Any());
return PersonNotes1;
}
 
I guess, the Person isn't visible to OrganisationContext. What line the debugger highlights?
var PersonNotes1 = _context.PersonNotes.Where(p => p.PersonId == personId);
 
Tom
The degbugger highlights at the line in class public class OrganisationContext : SagitarriContext
 
So, this can be because OrganisationContext doesn't see Person...
The code seems legit, but this is something with namespaces...
 
Tom
9:05 AM
HMM
 
 
1 hour later…
10:10 AM
So, have you found an error? )
 
 
2 hours later…
Tom
11:58 AM
Hi
What I have done is removed the declaration in the organisationcontext class and
refered to the model by the fullname like this
modelBuilder.Entity<Genistar.Organisation.Models.DataModels.Person>()
.HasMany(p => p.PersonNotes)
.WithOne()
.HasForeignKey(p => p.PersonId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_commonPersonNote_commonPerson");
Could you please take a look at this please
-1
Q: Entity Framework Core 3 - Missing type map configuration or unsupported mapping

TomI am trying to map entities in Entity Framework Core and getting the following error. I have two main entities Person and PersonNote which have a one-to-many relationship. One person can have many person notes. My method that I am trying to retrieve personotes does return a result but the fails...

 

last day (15 days later) »