I want to use sql raw query for better performance.
I was wondering if I could use context the same way as if I committed a query with linq. If I bind collection to dgv.DataSource and made some (update) could I call db.SaveChanges() to store the data in the database.
Example:
Using context = New BloggingContext()
Dim blogs = context.Blogs.SqlQuery("SELECT * FROM dbo.Blogs").ToList()
datagridview1.dataSource = blogs
' if I made some changes in datagridview1 could I
' use SaveChanges to commit any changes on button click
context.SaveChanges()
End Using
.Includemethod to include addresses in the same query or use a projection.SelectMany(p => p.Addresses).Select(a => new {FirstName = a.Person.FirstName, Stree = a.Street, ...}). This article doesn't use correctly EF and I don't recommend you to use raw SQL query for such simple query. If you have performance issue with EF, feel free to ask a new question :-)