Thank you very much for the video. Could we use the same approach to create a dynamic rule engine in c#? Something like some class, if, ( Name == "Test" and Age>20) then take some action? What I mean is, a rule engine editor where you define a rule body as mentioned and save it in DB and then load it and build the tree and run it on a type or collection and for every row meeting that criteria run the action defined in c#?
expression-json-serializer from aquilae or Serialize.Linq from esskar (both github repos) can serialize expressions. Never used them. But found them once.
@@StrikerJonny I think it is possible to save a postfix or prefix format of the rule in the DB and then load it parse it back as expression tree using stack. Just a guess!
@@rezarezash Sounds good. We do something similary at work, so our customers can build their own advanced search query. I dont know exaclty how we do that, but we use the saved expression to build an iqueryable, so efcore/db does the heavy load.
If I want to to create expression tree to sort on a generic child entity in Entity framework? It seems straightforward at first and the it explodes to something really really ugly...
I have a calculator, it take the user input from the textbox and show the result in a label, i knew about the tree expression. But no idea how i do it dynamicly, could u help me please thank u for your great tuto EX: 1÷3+2-4×3+15
Please for my sanity, why use this method over nameof()? I want to know real world applications for this so bad but i'm not sure this example is it, I hope you can prove me wrong
14:20 god damnit unary isn't pronounced like uninstall, it's pronounced like unity also + is not an operand, + is a binary operator, it's binary because it depends on two operands likewise, a unary operator has a single operand conditional operator is also called a tertiary because it has three operands
I think the first example isn't that good, just use nameof(User.Age)? Using functions just to get class members seems cumbersome and not really a real world use case. I think better example instead of just CreateUrl itself. Would've been a further function that runs code on a user. Based on the code it finds all the properties it needs for running the expression, to not request stuff it doesn't need. In this video you built something like CreateUrlFor(MyFunction) Where function takes user as argument and does stuff with it. I think a ExecuteWithData(MyFunction) Would be better. Where it iterates the whole MyFunction tree, and accumulates all properties on the User that are actually needed. Then generate url from that, request user, and execute MyFunction. That's a better real world use case I think. Don't need to show the actual http request and stuff, but I think that is a better to imagine use case. Hope my explanation makes sense, feels like it doesn't ^^
Mhm I think you missed the idea of the video, that we treat code as data, as long as you can see that it doesn’t matter what example I use. But I can’t remember what I said in the video exactly to reply properly sorry. But your example sounds exactly like what I would build it’s just there are time constraints on the video.
hands down this channel is a youtube gem, the stuff that you don't know where to find to learn them, you find them here
Cheers my dude )
Totally agree.
Wherever others leave off in videos from other channels, Raw Coding starts from there!
Shiet, my formula!
you said it brother
Literllay the only video that keeps solving my problems related to Expressions! Thank you!
The ONLY video that helped me understand such a hard topic. Thanks!!
Glad I could help!
I should thank you sir for such clear and concise explanations.👍
The best video on expression trees I have watched . Highly appreciated. cheers !
Ty for watching)
Great intro into expression trees. Trust you to make the hard stuff easy 🙌🏼
Thank you man, you really a hero.
Thank you 🙏
Another really really useful video, you re my google today, many thanks :D
Thank you for watching)
Loved the vid Mate, keep it up!
Cheers)
Amazing explanation, bro. Congrats.
Cheers
Great tutorial! Thanks a lot!
Thank you for watching
Thanks man... this is realy a good explanation for me!
Thank you for watching
Pure gold man
Cheers
Thank you very much for the video. Could we use the same approach to create a dynamic rule engine in c#? Something like some class, if, ( Name == "Test" and Age>20) then take some action? What I mean is, a rule engine editor where you define a rule body as mentioned and save it in DB and then load it and build the tree and run it on a type or collection and for every row meeting that criteria run the action defined in c#?
Yes some person goes in and configures a rule in a DSL and then you can resolve some handle that is possible :)
expression-json-serializer from aquilae or Serialize.Linq from esskar (both github repos) can serialize expressions.
Never used them. But found them once.
Thank you for sharing!
@@StrikerJonny I think it is possible to save a postfix or prefix format of the rule in the DB and then load it parse it back as expression tree using stack. Just a guess!
@@rezarezash Sounds good.
We do something similary at work, so our customers can build their own advanced search query. I dont know exaclty how we do that, but we use the saved expression to build an iqueryable, so efcore/db does the heavy load.
Great job 👏🏾
Thank you!!! You are the best))))
Cheers
If I want to to create expression tree to sort on a generic child entity in Entity framework? It seems straightforward at first and the it explodes to something really really ugly...
So it does, make functions and name them. Your functions are the tools that you should assemble in to the final product
awesome awesome stuff
Cheers
I have a calculator, it take the user input from the textbox and show the result in a label, i knew about the tree expression. But no idea how i do it dynamicly, could u help me please thank u for your great tuto
EX: 1÷3+2-4×3+15
You don’t need to use expression trees for a calculator, create operations as classes, use composition pattern
Thanks so much for this tutorial so interessing however witch IDE You have used to edit the tree structure
LinqPad
@@RawCoding thank u so much i ve already got the answer from zooming im the left top coin from the application ;)
I don't understand how the accessor expression took a lowercase selectproperty string (word) and knew to get someClass.Word not someClass.word
I'd not get too hung up on it - it probably handles lower case stuff
Please for my sanity, why use this method over nameof()? I want to know real world applications for this so bad but i'm not sure this example is it, I hope you can prove me wrong
nameof is compile time, expressions are runtime
14:20 god damnit unary isn't pronounced like uninstall, it's pronounced like unity
also + is not an operand, + is a binary operator, it's binary because it depends on two operands
likewise, a unary operator has a single operand
conditional operator is also called a tertiary because it has three operands
Please can you reccomend a c# textbook
I’ve never read one so no sorry
@@RawCoding love your videos
Thanks :)
hangfire also does this
What exactly?
@@RawCoding In hangfire the Enqueue method expects an Expression as the parameter
docs.hangfire.io/en/latest/background-methods/index.html
Thanks
Love your explanation and your style also :), but your audio volume is so low, even I have turned my audio level to the max.
Sorry about that, those were the times when I was still configuring my mic :P
Its not an operand, because an operand is a variable or value that an operator acts on. For example, a + is not an operand.
I think the first example isn't that good, just use nameof(User.Age)? Using functions just to get class members seems cumbersome and not really a real world use case.
I think better example instead of just CreateUrl itself. Would've been a further function that runs code on a user.
Based on the code it finds all the properties it needs for running the expression, to not request stuff it doesn't need.
In this video you built something like CreateUrlFor(MyFunction)
Where function takes user as argument and does stuff with it.
I think a
ExecuteWithData(MyFunction)
Would be better.
Where it iterates the whole MyFunction tree, and accumulates all properties on the User that are actually needed. Then generate url from that, request user, and execute MyFunction.
That's a better real world use case I think.
Don't need to show the actual http request and stuff, but I think that is a better to imagine use case.
Hope my explanation makes sense, feels like it doesn't ^^
Mhm I think you missed the idea of the video, that we treat code as data, as long as you can see that it doesn’t matter what example I use.
But I can’t remember what I said in the video exactly to reply properly sorry.
But your example sounds exactly like what I would build it’s just there are time constraints on the video.
nameof(new user().age), nameof(new user().name) this is also not error prone
Unary is pronounced as in Unicycle, Universe, United. *Not* as in onion, undead, unhelpful.
Сan i give you 100 likes? It was very helpful for me!
Of course you can! Glad I could help))
The audio glitches really kill my ears, with headphones
30:33
30:56
Apologies production issue :D