Everything You Need To Know About EF Core 8 Raw SQL Queries

preview_player
Показать описание

EF Core is one of the best ORMs out there. And it's getting an excellent new feature allowing you to query unmapped types. You can return data with SQL queries, views, functions, and stored procedures. EF Core is coming closer to Dapper with this feature, although the performance isn't there yet.

And I'll talk about SQL injection attacks and if there's a vulnerability.

Join my weekly .NET newsletter:

Read my Blog here:

Subscribe for more:

Chapters
0:00 What are Raw SQL Queries?
0:47 Introducing SqlQuery
1:46 What about SQL Injection?
3:41 Composing SqlQuery with LINQ
4:37 Introducing SqlQueryRaw
6:08 Creating a database view
6:47 Querying views with EF8 SqlQuery
Рекомендации по теме
Комментарии
Автор

Amazing as usual, thanks for keeping us updated

mohamed-hassan-
Автор

Excellent video .Thanks you for shared your knowledge .I hope to have more updates related.the topic

anthonyportilla
Автор

Hi Milan, thanks a lot for your videos 👍.
I'd like to know what in the best way to UNION using EF core ? even if the union was with the same table.
because I have an issue using it

Tamer_Ali
Автор

hey milan! hope you are good. Could you please make one video on how to get data in nested form using ef with stored procedures or raw sql.

bhbqott
Автор

Hi there, first of all, excellent video a question what it would be like with stored procedure in ef core 8?

anthonyportilla
Автор

How does it know to map the fields from the class OrderSummary to the fields from the database ? Like TotalPrice to total_price ?

fxandrei
Автор

How would it work with joins in Sql ? For example, if the view would return fields from multiples tables, each being mapped to different entities. From what I see, the SqlQuery would materialize only one entity.

nikogj
Автор

How can I configure
I am getting this error

The element type 'AuthAPI.Entities.User' used in 'SqlQuery' method is not natively supported by your database provider. Either use a supported element type, or use to define a mapping for your type.

Thanks in advance

hedrickgodsons
Автор

is there a github repo for this? I am wondering what the OrderSummary class looks like.

wusswuzz
Автор

Don't like the usage of the formattable string. This means it easy to move the declaration and initialization of the sql outside the invocation, implicitly declaring it with var will change the formattable string to a string, and suddenly, you have sql injection again. Is there an analyzer to notify you about this kind of usage?

svorskemattias
Автор

Hi Milan, is ef core doesn't support union AsQueryable?

coding-in
Автор

You don't know where to use Repository pattern. It is the best in its place.

shajareyetuba
Автор

then ppl can stop talk about sql injection on interpolated string

enricoroselino
Автор

I don't think it's a good thing for EF Core 8 to go to Raw SQL. ORM has a strong gender advantage for Entity, and Raw SQL can't report errors at compile time.

focyeeu