HAHAHAHAHAHA. Thank you. I haven't laughed that hard in a while :)
@HassanHabib3 жыл бұрын
LOL
@navdeepsingh94632 жыл бұрын
😂
@richardholguin34815 жыл бұрын
There are two types of developers, a LOT of stickers or NO stickers
@chadmwest5 жыл бұрын
Truer words have never been spoken.
@levinjay33765 жыл бұрын
Hahah! :)
@thilehoffer5 жыл бұрын
I have 3 stickers on my laptop.
@gabrielmoreyra33654 жыл бұрын
@Sharty Waffles Sure. That's why Jeremy is MVP and you're not.
@gabrielmoreyra33654 жыл бұрын
@Sharty Waffles I believe you they're experts. But I don't believe they got there by not sticking anything to their laptops.
@fabienl.75695 жыл бұрын
Who needs GraphQL when you have OData ? Wonderful! 🙌
@bryanwood99654 жыл бұрын
I always love Remote Code Execution
@userdfourdfive17885 жыл бұрын
This is great for simple solutions where EF context is tightly coupled to API. What about solutions that have a core project with domain models, services and repositories and where every piece is resolved dynamically when the solution is running?
@saravanansomu82967 ай бұрын
This is a great way to explain OData. Loved the grocery store analogy. thanks.
@BrendanKnowles5 жыл бұрын
Hassan, you're a legend - this is exactly what I was looking for!
@HassanHabib5 жыл бұрын
Thank you Brendan, I think the legends are the visionaries and engineers behind this technology, I'm just trying to bring their amazing work to light.
@F2H16 Жыл бұрын
Thanks, Hassan and Jeremy for such a nice intro.
@mihirp80135 жыл бұрын
Thanks for making OData super easy to implement with core! Can’t wait to add additional “4 Lines of Code” to all my API projects. 👍🏻
@yaynative4 ай бұрын
I love when standards are open and powerful.
@Night3scape5 жыл бұрын
Amazing, thanks a lot. that was amazing intro, now I need to figure out how to integrate it with ASPCore Policy Based Authorization, to control Entity extending and other OData Features..
@cmcki20085 жыл бұрын
This got to be the best video I’ve seen while working in IT. Thank you 😊
@HassanHabib5 жыл бұрын
Thank you for watching :-)
@RemusTMUTHOMI5 жыл бұрын
Great demo 👍👏, worth every second
@balramsingh47595 жыл бұрын
Very well explained, thanks
@rongliao92554 жыл бұрын
Great tutorial! Thanks a lot!
@tarakpatel854 жыл бұрын
$count is not working with endpoints.EnableDependencyInjection();, it works without and adding routeBuilder.MapODataServiceRoute("ODataRoute", "odata", GetEdmModel(app.ApplicationServices)); in .UseMvc(). Any suggestion how $count work with endpoints.EnableDependencyInjection()?
@hck1bloodday5 жыл бұрын
great lternative to the current trend of GraphQL, and i really like this approach , with graphQl you overfetch from the db nd filter on the server, this uses Entity framework to filter in the database
@marcel8305 жыл бұрын
You misunderstood GraphQL. You can also use the Entity Framework to filter in the DB.
@hck1bloodday5 жыл бұрын
@@marcel830 sure, but you have to spicify the queries that will apply those filters, then you loose the benefict over rest
@emaung4 жыл бұрын
Guys how can exposing the whole dbContext in controller to the world is the good idea?
@matiascasagrande77594 жыл бұрын
That is exactly what im asking to myself, also i just asked if there is a way to pass the filter options to an underliying layer like a Service Layer to perform the filtering in that layer and not in the controller
@abhishekbedre Жыл бұрын
If you notice, the response without the $expand and $filter the API follows the camelCase and once you add the $filter or $expand it omits the default camelCase.
@xelaksal66903 жыл бұрын
Magic:) Thank you for this demo.
@RaviMittal845 жыл бұрын
I have a question, Does that Odata operations happening directly on Database OR it's happening afterwards on the result set??
@HassanHabib5 жыл бұрын
If your return type is an IQueryable it runs on the database.
@@HassanHabib ya habib How about if it is entity framework?
@HassanHabib5 жыл бұрын
@@aah134-K if you materialize your data coming from EF as a list then it runs in memory, if you run on an IQueryable DataSet in EF then it runs on the database.
@odairto5 жыл бұрын
@@HassanHabib I did it and the SQL intercepted its a full SQL. This is my github, if you want to see: github.com/odairto/ODataEF
@rans01013 жыл бұрын
Great, thank you Hassan!
@borschetsky5 жыл бұрын
Amazing! Thank you a lot!
@LinusBenjamin5 жыл бұрын
Great stuff! Thanks a lot!
@stelathsyncllc10855 жыл бұрын
Really good stuff. Thank you.
@Emis3334 жыл бұрын
That's an amazing capability, good to know :)
@joshmccall5 жыл бұрын
Great video!
@Surenzzzaaa4 жыл бұрын
Thank You...
@arturoescutialopez19005 жыл бұрын
It would be great than you could map queried data to a DTO, for me It's not quite a good idea to allow your whole entity structure be shown to clients
@Emis3334 жыл бұрын
You can create automappers to map your model structure to a viewmodel structure where you show just enough.
@mkraft467 Жыл бұрын
Automapper and projection is working very well with OData and EFCore
@DunckingTest Жыл бұрын
omg this is awsome maaaagic
@ingamx4 жыл бұрын
thats really good. tnx
@matiascasagrande77594 жыл бұрын
Is there a way to inject the OData filtering capabilities outside the Controller? Like in a Service layer perhaps?
@subhashmishra23263 жыл бұрын
Nicely explained.. Awesome..Thanks a lot!
@WholeNewLevel20185 жыл бұрын
this is simply amazing
@BenHayat4 жыл бұрын
Two great guys.
@mhawkpiece5 жыл бұрын
Awesome!!
@puravupadhyay29612 жыл бұрын
When a another REST API is consumed by a Web API, is it a good idea to use OData?
@ASPCook4 жыл бұрын
I've seen a company that used OData in a large size application. And I only have one advise about it: OData or even GraphQL are good if you can chuck your application to small size services or you will close the door of updating your project to newer technolgies forever. Then the life will be so hard! :D
@LogicLabyrinth5 жыл бұрын
I wonder if this implementation is paving the way for support for GraphQL, or will it always be a divergent solution? At minimum, definitely a promising addition for standard APIs.
@HassanHabib5 жыл бұрын
OData actually existed before GraphQL, in fact OData is a lot more powerful than GraphQL check out the comparison here: www.progress.com/blogs/rest-api-industry-debate-odata-vs-graphql-vs-ords
@Ashwath-p8c5 жыл бұрын
Nice video! 2 questions. 1. If I have a response like this { id:"123", "metadata": { "branch": "master" } }, { id:"1234", "metadata": { "branch": "master" } }, { id:"1235", "metadata": { "branch": "master1" } }, how do I $select just the branch property? 2. How can i select only the distinct branches? (master and master1 in this case?)
@akuhndevelopers19895 жыл бұрын
Supper amazing!!
@EaswaranParamasivam4 жыл бұрын
It saves more time.. thanks!
@kalaiselvanra5 жыл бұрын
Interesting stuff.
@alexandershubert573 Жыл бұрын
Amazing, how now with .net 6 all of this needs to be re-recorded
@bullsinhell5 жыл бұрын
Hassan - First of all, a really cool demo. Is it possible to use the above with a return type as HttpResponseMessage for my Get action (.NET Core 2.0 - Web API)?
@Turbosmurfen734 жыл бұрын
Love it!
@tuhamustefa65883 жыл бұрын
WoW, it's super Amazing
@acidfoxx523 жыл бұрын
What reference is being used that is not part of the "4 lines" of code?
@ThoNguyen-ns6jh Жыл бұрын
good job, thanks
@Robinhopok5 жыл бұрын
Really interesting. Are there any libraries which make generating Typescript clients possible? I'm also curious if OData can be used for add/update/delete operations. I guess I'll check out the docs!
@HassanHabib5 жыл бұрын
Of course, we will be discussing this in detail in an upcoming videos.
@sugeshangovindsamy6220 Жыл бұрын
Wow !!! So you can code and be the best football player in the world 🤣🤣🤣🤣🤣
@cyril1132 жыл бұрын
The funny thing is, the initial JSON response had lower case keys and the OData responses capital case keys. Pascal case is just weird.
@mkraft467 Жыл бұрын
Thanks guys amazing demo. But I have one question which I am having a hard time to figure out: is it possible to have both the existing WebAPI and the OData service leaving side by side but to access it with a different prefix like this ? api/Students -> WebAPI odata/Students -> OData I am using .NET 6 / AspnetCore.OData 8
@DennisTuckersAwesome4 жыл бұрын
When I download the example and run it, it brings back the student and the school when I just request students.I thought you would only get students and if you did expand=School then you would get school info? The sample code doesn't behave like the video.
@marianbencat66585 жыл бұрын
So... it is basically method interceptor / middleware.. right? Exposing IQueryable is good only for pretty small applications (RAD), because it is leaky abstraction - even with queryable mapping. This is mapping Querystring -> LINQ expression. Despite i am big critic of GraphQL/ ODATA because of their low usability in real big and performant applications i liek this idea, because it is easy to use and cool transfer-size optimizations. @hassan how does the expand work without EF and .include() extension method? Just ignored? or you can modify mapping of that via configurations?
@12SecondsToLive5 жыл бұрын
The end of video mention it works with Classic ASP.NET, I assume that's ASP.NET WebAPI .NET Framework? Is there an example setting that up?
@HassanHabib5 жыл бұрын
Yup, that's exactly what I meant, in fact it's even simpler in ASP.NET Web API with .NET Framework, you still gonna have to add OData service, but then you don't have to do the dependency injection part, just add [EnableQuery] to your controller and you should be good to go!
@HassanHabib5 жыл бұрын
Here's an example: kzbin.info/www/bejne/qJK1dIhoqMd3ick
@satish80005182895 жыл бұрын
Thank you Friends. it was awesome experience. I have worked with repository patten in that case what i can do.
@HassanHabib5 жыл бұрын
Still works, as long as your repository object returns an IEnumerable or IQueryable.
@gleamofcolor3 жыл бұрын
Those 4 lines of code did work in .net core 3.1 . I have to do other config changes as well. Pls update this video with latest .net core version at least 3.1 onwards
@JuanDavidMaya3 жыл бұрын
if a want to have this automatically for every table in my database how I could achieve this without using Entity Framework and map every table manually?
@DutchThought4 жыл бұрын
When can we plug this into 3.1? Great work.
@offline_meetup4 жыл бұрын
I didn't test it yet, but here is an article from Hassan about OData in asp.net core 3.1 devblogs.microsoft.com/odata/experimenting-with-odata-in-asp-net-core-3-1/
@baris79715 жыл бұрын
oData is great. But sadly it breaks Swagger API Doc. Is there any Workaround for this behaviour?
@dhanushkakodituwakku51655 жыл бұрын
What's the best approach to make it case insensitive?
@JH-qe3fu5 жыл бұрын
Answer is?
@andreigalkin3 жыл бұрын
Hey. Is any one seen a recent example how to unit test a controller with ODataQueryOptions filter. I am having a trouble to create it of mock it. All example which i found do not work with the .net 5. Thanks
@songlover10722 жыл бұрын
how to get the XML response with OData? because I'm having a problem retrieving it, hope anyone could help.
@arunkumarparthasarathy64245 жыл бұрын
Superb
@klfr29003 жыл бұрын
Isn´t OData also about the format, not only how to query the data? Does this also comes with the ASP.NET Core OData Package, how many lines of code would it took to add that? :)
@userdfourdfive17885 жыл бұрын
Is there some possibility with the Expand feature to expand to only one level of relationship and not unlimited levels. This will prevent the user to query the whole database.
@idgafa4 жыл бұрын
[EnableQuery(MaxExpansionDepth = 1)]
@jo0h4n184 жыл бұрын
If you're having an api which executes an specific store procedure for that specific endpoint, then you can change the output by altering the store procedure right? This can be done without having to build and release an new version of the api that now needs a new functionality to the routebuilder.
@sehulugh3 жыл бұрын
Wow, I got an Api to add a few lines of code and a client App to rebuild, thanks
@guillermoacosta88495 жыл бұрын
Hi @ Hassan Habib! Great video and explanation! Thank you! I have a question: to practice, I'm play around Chinook databases (do you know?), and "expand" don't work for me, using it like you in your video. The result json show the value items like [ ]. The relation on databases through foreing key, indexes, etc are fine. Summarizing, it does not show the values tied by navigation properties. Please, can you give me any clue that may be failing? Thanks in advance!
@joelmamedov4044 жыл бұрын
Well, if you want the client-side capability more than service end-point can provide, then, in essence, you need to write SQL type query. To do that, you need to know the data schema of the source system. If you are going to that direction, then I would question the whole idea of the service concept and service encapsulation.
@MrKhaledpage4 жыл бұрын
well explained!
@MichaelRosendahl20135 жыл бұрын
Nice demo, specially if you have an open API, but is there any way to map queries to DTOs and more importantly use AuthorizationHandler?
@rcardare5 жыл бұрын
Needs more dynamic/non-sqlserver/large dataset examples. I had to pass on this framework as it wasn't abstract enough for a simple json response. Current framework should be filed under the EF namespace and not a standalone product.
@HassanHabib5 жыл бұрын
That's not true actually, you can build a simple controller that returns a hardcoded list of values and OData will still query and filter - not EF specific.
@rcardare5 жыл бұрын
I'll try it out again as I am sure things improved. Last I remember only small tables in sql were really supported, everything else killed performance or required a lot of work to implement custom EF providers in .net core. I am working on a system to abstract old databases (sql, oracle, etc) and some instances are very old and large. I had problems the last time I researched this so maybe it worth checking out again. Thanks
@HassanHabib5 жыл бұрын
@@rcardare let us know how it goes.
@UniversB34 жыл бұрын
Très belle démonstration d'OData, Merci. J'aurai bien aimé savoir comment et surtout à quelle moment les données sont traités (filtre, select,... ) Est ce que c'est vraiment au moment de l'exécution de la requête dans la base de données où une fois remontée, mais ça reste en mémoire côté serveur ? Merci beaucoup
@y.51075 жыл бұрын
Why is it bad to use a field like _context in this example? Was his only point to skip the underscore/rename it and use this.context instead?
@HassanHabib5 жыл бұрын
Use a prefix for field names doesn't follow C# naming conventions/guidelines, this was a practice that was carried over from C++, here's the coding guideline reference: docs.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members This also is a good reference: docs.microsoft.com/en-us/dotnet/standard/design-guidelines/general-naming-conventions
@hamedmohammadi13985 жыл бұрын
wow, i think MS really should focus on trending this stuff, this is like graphql but has been around since 2007, yet everybodey just talk about graphql and how its gonna change the world but it came to play in 2015
@thilehoffer5 жыл бұрын
Does this work with .net Core 3.0?
@HassanHabib4 жыл бұрын
Yes, here's how to do it: devblogs.microsoft.com/odata/experimenting-with-odata-in-asp-net-core-3-1/ and here as well: devblogs.microsoft.com/odata/enabling-endpoint-routing-in-odata/
@martinscheringa87653 жыл бұрын
If i query schools and want to $epand all the students as a list it is not working. Can any one tell me what goes wrong?
@kafoly19805 жыл бұрын
Just a remark. Don't confuse expand and navigation this is not exactly the same concept: - expand : you get the root entity (student) and related entity(school) in one request by giving the name of navigation in the expand parameter. So expand is based on navigation. - navigation: You get additional information on the root entity by calling a navigation on another entity (and target property). This additional information will trigger another request than the primary request on the root entity.
@consolednd5 жыл бұрын
For the secure reason, I don't want to share full entity from DataContext. Can I use OData for IQueryable instead of an entity?
@HassanHabib5 жыл бұрын
Yes of course, you have full control over your return type on the controller method.
@borceacristian4344 жыл бұрын
amazing
@DennisTuckersAwesome4 жыл бұрын
Is there a git repo for this example?
@dotnetdevni5 жыл бұрын
What about auto lookup the schools against the school name
@HassanHabib5 жыл бұрын
You can using filtering to do that, so you can do $filter=Name eq 'School Name Here' something like that.
@elgunlee5 жыл бұрын
Hi. I hava a question. Is routeBuilder.EnableDependencyInjection(); required? As far as I know we can already use DI in controllers without writing this.
@HassanHabib4 жыл бұрын
Yes, it's required for your non-Edm route
@ibrahimozgon5 жыл бұрын
Does OData query on DB via Entity framework or does it only query on the results?
@HassanHabib5 жыл бұрын
It depends on the return type, if your controller method is returning a IEnumerable it will perform differently than if it was returning IQueryable. if it's IQueryable OData will perform the search on the database via EF, if it's IEnumerable it will perform the query on the returned results. hope this helps.
@ibrahimozgon5 жыл бұрын
@@HassanHabib This is great answer and really great feature. Thank you for the very informative video
@davidpereira69825 жыл бұрын
@@HassanHabib This is awesome, because I guess most of ASP.NET Core APIs return IEnumerables from the injected services in the controllers. If you only need 4 lines of code to do all of this, it's f*cking magic! I would like to know how performance is affected with OData, but so far it's quite impressive. Thank you guys, loving all your stuff you are doing and I really hope .NET Core 3 will be a boom in the Software Development world.
@somebodytocode5 жыл бұрын
impressive
@ericjhuneespa33815 жыл бұрын
When i use odata with async task await . . using the expand .. it is not working why ??
@王大爷-s6p5 жыл бұрын
能不能加个中文字幕,Please add Chinese subtitles, thanks
@ismaegonzales5Ай бұрын
Esto me ayuda mejorar 🎉😊
@santosh5678905 жыл бұрын
This looks interesting. I was trying to add routeBuilder to - app.UseWebApi() ( my app uses this). But I am not able to pass the routeBuilder predicate to this. Can someone help me out please?
@HassanHabib5 жыл бұрын
Could elaborate more? what are you trying to do?
@santosh5678905 жыл бұрын
@@HassanHabib In Startup Configure(IAppBuilder) -> i am using app.UseWebApi(config) instead of UseMvc. And UseWebApi does not have routebuilder as argument. Can we somehow make this work with webapi as well?
@HassanHabib5 жыл бұрын
@@santosh567890 I see. if you're okay with going to 6 lines of code instead of 4 - you can do this: gist.github.com/hassanhabib/a63297a55e802157b353525c9d420363
@julioalmeida46455 жыл бұрын
Show now an integration of OData with Swagger and you will have my slow clap
@mspasiuk5 жыл бұрын
Same here, I added the OData to my controller, and works, but swagger don't. Im using net core 2.1
@HassanHabib5 жыл бұрын
@@mspasiuk I'm working with the OData team to get this officially released - should be out officially shortly.
@vincentnwonah76375 жыл бұрын
@Hassan Habib Thanks!
@aah134-K5 жыл бұрын
🤣🥳🥳🥳
@erichughes14605 жыл бұрын
i did it at work this month ;)
@farrukhkhan9675 жыл бұрын
How did you came out of this error "IServiceCollection' does not contain a definition for 'AddOData' and no accessible extension method 'AddOData' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)" P.S: I am using the same directive as you used. i.e. using Microsoft.AspNet.OData.Extensions; please help me.
@HassanHabib5 жыл бұрын
Did you install the right nuget package?
@farrukhkhan9675 жыл бұрын
@@HassanHabib I figured it out. Thanks. I was using .net core for OData and we need other nuget package i.e. .netcore package to install and then do the samething.
@Impenneteri5 жыл бұрын
Isn't this the same with APIs that uses RQL?
@HassanHabib5 жыл бұрын
Very, very similar, Open Data Protocol has a lot of different implementations RQL seems to be one of these implementations.
@alexandredanelon5 жыл бұрын
It's a big feature, I need to change from .NET Framework to .NET Core fast...
@HassanHabib5 жыл бұрын
You can also have OData in .NET Framework if you want, it's also available in there.
@KarlRhodesUK4 жыл бұрын
Cool... Now how do I use consume an OData service in ASP.Net Core 3?
@kristjankica74714 жыл бұрын
Not compatible with 3.0
@GregerHagstrom5 жыл бұрын
Hassan didn't go to the "amount of stickers" meeting
@HassanHabib5 жыл бұрын
LOL
@rokinroj5 жыл бұрын
I need to talk about your flair. Now, it's up to you whether or not you want to just do the bare minimum. Well, like Jeremy, for example, has 37 pieces of flair.
@HassanHabib5 жыл бұрын
@@rokinroj "I do want to express myself. And I don't need thirty-seven pieces of flair to do it. " Haha
@bobbyv35 жыл бұрын
Are those 13 or 15" Surface Book 2s?
@HassanHabib5 жыл бұрын
15" :-)
@UnrealSPh5 жыл бұрын
Hi! Good video, thank you! What about restier for asp.net core?
@HassanHabib5 жыл бұрын
Thank you for watching, we will try to address that.
@brunoccs5 жыл бұрын
Is it affecting the database query or just the return from the API?
@HassanHabib5 жыл бұрын
If you're returning an IQueryable, it will run on the database.
@jacobneroth4 жыл бұрын
Out of context , how you do map open types in odata to entity framework core ?