There's a way with Database.SqlQuery to return the new object created ?
With Linq I do it this way :
Category category
db.Categories.Add(category);
db.SaveChanges();
return category;
Now category is an object that return the new category created with the new id.
How to do it with SqlQuery?
return db.Database.SqlQuery<Category>("INSERT INTO " + categoryTable + " (title,description) VALUES ({0},{1}) ", category.title, category.description);
It returns a empty array but i want to return the new category created with the new id.
Thank you.
db.Database.Log=Debug.WriteLine;before you did your LINQ, and see what it generates.db.GetTable("yourtable").Add(category); db.SubmitChanges():