GABRIEL22
GABRIEL22
CC#
Created by GABRIEL22 on 1/15/2024 in #help
System.NullReferenceException: Object reference not set to an instance of an object.
I mean the Subject exist in the database. I'm using data seeded of database migration.
16 replies
CC#
Created by GABRIEL22 on 1/15/2024 in #help
System.NullReferenceException: Object reference not set to an instance of an object.
To get a subject by his id (primary)
16 replies
CC#
Created by GABRIEL22 on 1/15/2024 in #help
System.NullReferenceException: Object reference not set to an instance of an object.
The error occur when I tried to access the object to check if is null :
cs

if(subject.TeacherDni == null)
cs

if(subject.TeacherDni == null)
16 replies
CC#
Created by GABRIEL22 on 1/11/2024 in #help
How succesfully set a Database Relationship in .net?
I remove it with TeacherDni?
13 replies
CC#
Created by GABRIEL22 on 1/11/2024 in #help
How succesfully set a Database Relationship in .net?
So, the solution is set the foreign key in the teacher model?
13 replies
CC#
Created by GABRIEL22 on 1/11/2024 in #help
How succesfully set a Database Relationship in .net?
I tried what the error told me to do it. I set the foreign outside the Subject model. Still throwing the same error, but with diferent parameters.
13 replies
CC#
Created by GABRIEL22 on 1/10/2024 in #help
How to fix " The ConnectionString property has not been initialized." in .Net api
No, I'm using GitHub Codespaces which is a online ide. Should I set the string config in db context rather than Program.cs alone. I didnt use OnConfiguring method because I though setting the Postgres connection string in Program.cs was enough.
7 replies
CC#
Created by GABRIEL22 on 1/10/2024 in #help
How to fix " The ConnectionString property has not been initialized." in .Net api
I already tried, and it didn't workout as expected.
7 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
Thank you for the help! I'm going to make the changes you suggest me.
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
I'm using a In-Memory database.
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
How can I unit test this function? I have to unit first test.
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
Without Id in the way, and just with number of teacher and that stuff?
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
But, in the Controller, the way I add the teacher into Subject is fine? Or should I approach it another way?
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
Do I substract the nullable property? I know a Id couldn't be undefined.
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
Yes, a Subject has a single teacher, and I establish a Count function to check if a Subject already contain a Teacher, if is not, then it add the Teacher into Subject. But the problem is I'm not sure if I did ok nor how to unit test it,
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
This is how I did: public IHttpActionResult EnrollTeacher(string id) {
var subject = _repo.GetById(id); var teacher = _repo.GetTeacherbyId(id);
if(_repo.teacherCount() > 1 && subject != null) { Console.WriteLine("Teacher already set up"); } else { subject.TeacherId = teacher.id; } return Ok(subject);
}
50 replies
CC#
Created by GABRIEL22 on 1/4/2024 in #help
How to add data into one-to-one relationship
I dont know this is the model I've got. I doubt the value is undefined
50 replies