While trying to use LINQ to SQL, I ran into several problems.
I have table faces:
- int ID
- string firstName
- string lastName
And tabular notes that have:
- int ID
- string noteText
- createdBy string
- datetime creationDate
- int PersonID
PersonID is a foreign key, and the ratio is 1: n
I tried using LINQ to SQL to create a person and some notes for each person.
Person person = new person(); Person.firstName = "me"; Person.note = new note(); Person.note.noteText = "some textโฆ"; _DataContext.Persons.InsertOnSubmit(person); _DataContext.SubmitChanges();
The problem is that the human object does not yet exist in the database, so it does not yet have an identifier. Thus, the note.personID file has the value 0 ... (the ID field is the identification field on the sql server)
The only solution I found for this is to create a person, submit, and then re-create a note and sign.
Am I missing something here, or perhaps the way I need to work with LINQ to SQL?
How to add a few notes per person using LTS? I have a 1: n ratio and I do not see it with LTS.
If a person has 10,000 notes, I donโt want the constructor of the personโs object to load all the records that he has. I want to download them only when I access them. How can I configure LTS to load notes upon request?
source share