I have 2 tables:
tblAuthors
- id
- username
tblPosts
- id
- authorid
So if I create a new Post
var post = new Post { Id=Guid.NewId(), Author=new Author { UserName="username", Id="id in database } };
The author of the post is already in the database, but the post itself is not...
So I want to do:
entities.AddToPosts(obj);
but it tries to add the Author and the Post... is there a way to have it Save the author and add the post? Or just ignore the Author completely?
I have both the Post and the Author as my own POCO business objects, that were pulled from the database and then converted to my business layer. I don't want to have to re-pull them because I could have modified either in my business layer. So I just want to attach the objects.
I don't want to keep the data objects around, I pull them out and convert them to business objects and then don't touch them again until I want to push back to the database and I convert the business objects to data objects.