00:00:16.480 --> 00:00:18.890 Yep, for the front end. Does. Hell yeah.
00:00:18.770 --> 00:00:21.627 Yeah, we're going to do some. So we're going to show back end are
00:00:21.627 --> 00:00:24.139 getting shown some basic front end stuff and I'm gonna be
00:00:24.139 --> 00:00:26.390 walking you guys through some basic back end stuff.
00:00:27.480 --> 00:00:30.617 Uh, so the main thing that I wanted to cover here and again,
00:00:30.617 --> 00:00:33.806 I'm going to share my screen really fast is just sort of like
00:00:33.806 --> 00:00:35.040 terminology and whatnot.
00:00:36.140 --> 00:00:40.210 And getting you guys familiar with like where some things are
00:00:40.210 --> 00:00:43.886 and what some things mean. So that if you need to debug
00:00:43.886 --> 00:00:47.628 something or if you want to try and fix something or add
00:00:47.628 --> 00:00:51.961 something or whatever, you'll at least have a sort of springboard
00:00:51.961 --> 00:00:54.390 to get you where you need to go. So.
00:00:56.180 --> 00:00:59.490 To start with, I'm curious if you guys have any questions
00:00:59.490 --> 00:01:03.142 about anything on the back end. Like if there's any terminology
00:01:03.142 --> 00:01:06.110 and don't feel like any question is a bad question.
00:01:06.790 --> 00:01:10.191 All of the you know, computer, computer, people like to name
00:01:07.240 --> 00:01:07.650 Yeah.
00:01:10.191 --> 00:01:13.648 things really weird things. So if there's words or phrases or
00:01:13.648 --> 00:01:17.160 terms you're not familiar with, by all means feel free to ask.
00:01:18.260 --> 00:01:20.030 So yeah, Alex, whatever you got.
00:01:20.640 --> 00:01:24.123 Umm. Whenever you open up a solution in Visual Studio we
00:01:24.123 --> 00:01:28.155 have like those the folders that are numbered. Can you go through
00:01:27.490 --> 00:01:27.760 Umm.
00:01:28.155 --> 00:01:31.210 like what each folder, what the content of it is?
00:01:29.740 --> 00:01:30.020 Yeah.
00:01:31.490 --> 00:01:35.488 Yep. So that was actually gonna be exactly the the direction I
00:01:35.488 --> 00:01:36.440 went with this.
00:01:40.250 --> 00:01:41.010 Uh.
00:01:44.980 --> 00:01:48.509 So yeah, uh, sorry, reading messages. So yeah, there are
00:01:48.509 --> 00:01:51.480 numbered specifically because they're oriented.
00:01:52.290 --> 00:01:56.425 In the sort of the order that they depend on each other, if
00:01:56.425 --> 00:01:59.250 that makes sense, so generally speaking.
00:02:00.190 --> 00:02:04.589 Things reference things above them and never below them, so 00
00:02:04.589 --> 00:02:08.359 core isn't referencing data access layer or models or
00:02:08.359 --> 00:02:11.920 providers and providers isn't referencing portals.
00:02:12.820 --> 00:02:17.058 Uh, but portals is referencing business logic and providers is
00:02:17.058 --> 00:02:20.825 referencing models and et cetera. And so that's sort of
00:02:20.825 --> 00:02:24.794 the reason for the numbering specifically and it's sort of
00:02:24.794 --> 00:02:25.870 lays things out.
00:02:27.190 --> 00:02:30.987 Architecturally, if you will so starting at the top in the core
00:02:30.987 --> 00:02:34.606 folder, generally speaking, you probably won't have to touch
00:02:34.606 --> 00:02:38.285 almost anything in here except for the configuration project.
00:02:38.285 --> 00:02:41.964 The rest of these are these, just have like some utilities in
00:02:41.964 --> 00:02:45.346 them. So if you've ever seen like the contract dot check
00:02:45.346 --> 00:02:49.143 valid ID or check valid key or whatever on the back end, that's
00:02:49.143 --> 00:02:52.940 this class right here that's in this file. So all those tons of
00:02:52.940 --> 00:02:55.610 helper methods are all defined in this file.
00:02:57.100 --> 00:03:00.554 And I'll talk a little more about that in a bit. UM, ignore
00:03:00.554 --> 00:03:04.065 this JS configs folder that needs to be moved. You know, I'm
00:03:04.065 --> 00:03:07.864 just basic stuff. Lives in here. Nothing you really ever going to
00:03:07.864 --> 00:03:11.030 change? Same with the encryption. Same with utilities.
00:03:12.210 --> 00:03:15.110 The registry loader is really important to have a vague
00:03:15.110 --> 00:03:17.959 knowledge of. Again, you probably never have to modify
00:03:17.959 --> 00:03:20.859 anything in this project, but it does have. You will be
00:03:20.859 --> 00:03:23.811 interfacing with it very frequently if you write back in
00:03:23.811 --> 00:03:24.070 code.
00:03:25.770 --> 00:03:28.977 And I'll talk a little bit about that here in a minute. The one
00:03:28.977 --> 00:03:31.934 you're gonna see the most often, and the one that you guys
00:03:31.934 --> 00:03:35.041 probably are already somewhat familiar with is configuration.
00:03:35.041 --> 00:03:37.897 This is where all your app settings live. So you've seen
00:03:37.897 --> 00:03:40.703 all these CEF config dot properties. 1234 of these have
00:03:40.703 --> 00:03:43.810 your app settings, keys, types, summaries and all that stuff.
00:03:44.500 --> 00:03:45.130 Umm.
00:03:47.050 --> 00:03:51.367 And then for the front end, the way that that that endpoint
00:03:51.367 --> 00:03:55.540 actually gets its data, so I'll show you guys real quick.
00:03:56.740 --> 00:03:59.110 The way that the.
00:04:00.240 --> 00:04:04.671 This data actually gets populated right here. All this
00:04:04.671 --> 00:04:07.410 storefront CEF config call is by.
00:04:08.560 --> 00:04:11.595 This CEF config dot gets storefront class right here. It
00:04:11.595 --> 00:04:12.980 spits out the whole thing.
00:04:13.620 --> 00:04:16.855 Umm. Now I'm not looking at latest Sev so I'm going to
00:04:16.855 --> 00:04:19.620 switch over to a more recent version of stuff.
00:04:21.030 --> 00:04:22.420 And use this one.
00:04:23.190 --> 00:04:24.740 Be a little bit more up to date.
00:04:25.320 --> 00:04:26.170 UM.
00:04:27.260 --> 00:04:31.127 But yeah, uh, so configuration is where all this stuff is going
00:04:31.127 --> 00:04:35.114 to live. If you create a new app setting that the front end needs
00:04:35.114 --> 00:04:38.739 to know the value of for any reason, then what you'll do is
00:04:38.739 --> 00:04:42.666 you can follow the template for any one of these like CEF config
00:04:42.666 --> 00:04:46.352 dot properties, whatever. So for example, let's say for some
00:04:46.352 --> 00:04:50.218 reason you want the front end to know that badges is enabled or
00:04:50.218 --> 00:04:53.360 we create a new setting in here that's like static.
00:04:54.110 --> 00:04:56.440 Uh badges visible.
00:04:57.270 --> 00:05:00.125 On storefront, I don't know, I'm just making something up. Uh,
00:05:00.125 --> 00:05:02.617 you can just sort of copy the template from some other
00:05:02.617 --> 00:05:02.980 setting.
00:05:03.700 --> 00:05:06.748 Uh, I don't know why badges depend on stores, but I don't
00:05:06.748 --> 00:05:10.058 really care in this case. We're gonna depend on badges enabled
00:05:10.058 --> 00:05:12.160 instead, because that just makes sense.
00:05:12.920 --> 00:05:16.000 UM and give it a key that makes sense.
00:05:18.010 --> 00:05:21.670 OK, so we have a setting now. Cool. If you want this to be
00:05:21.670 --> 00:05:25.516 mapped to the front end, then what you wanna do is go look at
00:05:25.516 --> 00:05:29.362 get storefront and you can see what all this does which has a
00:05:29.362 --> 00:05:33.332 get connected, crawl through and keep keep poking to figure out
00:05:33.332 --> 00:05:37.178 what you need. But we have this git storefront inner and then
00:05:37.178 --> 00:05:41.210 down here we've got all kinds of crap. And if I recall somewhere
00:05:41.210 --> 00:05:41.520 is a.
00:05:43.350 --> 00:05:44.440 I have to scroll a bit.
00:05:47.210 --> 00:05:50.363 As like a gift feature sets. Yeah, there it is GIF feature
00:05:50.363 --> 00:05:53.302 set. UM, well, badges are obviously features. So we're
00:05:53.302 --> 00:05:56.776 gonna go in here and find this. And now there's feature set. And
00:05:56.776 --> 00:06:00.036 look, there's badges, cool. And then we can go over here and
00:06:00.036 --> 00:06:00.250 add.
00:06:00.870 --> 00:06:04.422 Uh, what? Visible in store front. I think I called it on
00:06:04.422 --> 00:06:07.974 storefront over there, which is dumb, but we'll we'll be
00:06:07.974 --> 00:06:08.660 consistent.
00:06:09.430 --> 00:06:15.208 UM, and then we've got visible badges visible on storefront to
00:06:15.208 --> 00:06:16.950 string 2 low order.
00:06:18.120 --> 00:06:20.630 UM, trailing comma for sanity.
00:06:21.950 --> 00:06:23.810 And yeah.
00:06:24.690 --> 00:06:28.074 Uh, why is there an error? There was a complaint about expected
00:06:28.074 --> 00:06:29.660 expression. Well, get over it.
00:06:31.660 --> 00:06:34.515 It'll figure it out. So yeah, that would create a new setting
00:06:34.515 --> 00:06:37.509 that now maps to the storefront. So when you change the value of
00:06:37.509 --> 00:06:40.411 this setting, you'll get it on CEF configs and the storefront.
00:06:40.411 --> 00:06:43.220 Yeah, obviously you need to add like on your front end code.
00:06:45.670 --> 00:06:46.760 There's like the.
00:06:49.250 --> 00:06:51.420 So if config dot TS or something like that.
00:06:53.440 --> 00:06:54.320 Uh.
00:06:55.260 --> 00:06:56.500 Yeah, I'll find it in here.
00:07:00.140 --> 00:07:02.620 Take me there. OK or don't? That's fine.
00:07:04.560 --> 00:07:08.067 Yeah, cool. You'd find the feature set thing in here and
00:07:08.067 --> 00:07:11.697 add into here which badges has ice simple enabled feature.
00:07:11.697 --> 00:07:15.573 You'd you'd have to do like a couple ways you could do it. You
00:07:15.573 --> 00:07:16.680 could do like and.
00:07:17.450 --> 00:07:17.720 You know.
00:07:18.600 --> 00:07:21.906 And in the long storefront, Boolean or something like that,
00:07:21.906 --> 00:07:25.433 whatever. However you feel like adding that to the front end so
00:07:25.433 --> 00:07:28.574 you can read it and you're actual TypeScript. But that's
00:07:28.574 --> 00:07:31.880 the process. If you were to wanna create a new app setting.
00:07:32.580 --> 00:07:33.260 And.
00:07:33.880 --> 00:07:36.072 Put it somewhere on the. I'm going to close this other one so
00:07:36.072 --> 00:07:36.850 it doesn't confuse me.
00:07:38.390 --> 00:07:41.978 And put it on the store front. So I'm gonna get rid of that
00:07:41.978 --> 00:07:45.565 stuff. So that's the main thing. You're probably gonna come
00:07:45.565 --> 00:07:49.153 across if you're looking at anything in 00 core is gonna be
00:07:49.153 --> 00:07:49.990 configuration.
00:07:50.690 --> 00:07:56.057 Umm, I'll talk more about the registry later when we get to
00:07:56.057 --> 00:08:01.871 code that actually uses it, but the short answer to the registry
00:08:01.871 --> 00:08:07.148 loader and what purpose it serves is it's a confusing term
00:08:07.148 --> 00:08:08.400 for it maps A.
00:08:09.890 --> 00:08:13.591 And interface to an implementation, UM, and I'll
00:08:13.591 --> 00:08:16.990 talk about interfaces and classes and stuff.
00:08:17.210 --> 00:08:20.920 Uh, you know what? Right now I will.
00:08:22.560 --> 00:08:26.785 So in TypeScript you guys have a concept of interfaces, classes
00:08:26.785 --> 00:08:28.700 and types and all that stuff.
00:08:29.580 --> 00:08:33.910 That works pretty fundamentally differently than it does in C#.
00:08:34.470 --> 00:08:39.040 Umm. And So what I'll show.
00:08:40.610 --> 00:08:45.103 I think here we could place to like just get a scratch pad
00:08:45.103 --> 00:08:45.560 going.
00:08:48.030 --> 00:08:48.650 Sure, why not?
00:08:53.000 --> 00:08:55.620 So we'll just hang out down here so.
00:08:57.440 --> 00:08:58.840 In C#.
00:08:59.780 --> 00:09:05.533 Uh, there are two primarily primary distinctions for a type
00:09:05.533 --> 00:09:10.710 of object. There are value types and reference types.
00:09:12.970 --> 00:09:19.035 A value type is like a bool or an int, or a float, or et
00:09:19.035 --> 00:09:19.780 cetera.
00:09:21.780 --> 00:09:23.320 These are types that.
00:09:24.050 --> 00:09:29.637 Uh, the value of the object is is. It's hard to explain this in
00:09:29.637 --> 00:09:35.050 a way that doesn't sound overly complicated, but the value of
00:09:35.050 --> 00:09:40.201 the object is the memory it consumes. The bool variable is
00:09:40.201 --> 00:09:43.780 true or false. A reference type is that.
00:09:44.760 --> 00:09:49.698 Is anything else a strings? Any object types like that? Anything
00:09:49.698 --> 00:09:54.332 else that's not like a plain old singular piece of data is a
00:09:54.332 --> 00:09:59.042 reference type in C and what that means is that the reference
00:09:59.042 --> 00:10:03.828 here the variable path is not the string, it's not the list of
00:10:03.828 --> 00:10:08.235 characters. It's actually technically a reference to that
00:10:08.235 --> 00:10:10.210 memory somewhere else and.
00:10:09.530 --> 00:10:12.511 Just just interrupt you real quick for for what it's worth,
00:10:11.680 --> 00:10:11.960 Yeah.
00:10:12.511 --> 00:10:14.350 the JavaScript does that same thing.
00:10:14.620 --> 00:10:17.060 Yes it it has similar behavior, yeah.
00:10:15.340 --> 00:10:17.520 So they might already know that, yeah.
00:10:18.190 --> 00:10:22.232 Yeah. So ultimately, if you guys, I if you guys are familiar
00:10:22.232 --> 00:10:26.273 with any sort of lower level languages like C or C reference
00:10:26.273 --> 00:10:30.381 types are sort of like pointers in those languages and that's
00:10:30.381 --> 00:10:34.158 the same for JavaScript reference types, is that they're
00:10:34.158 --> 00:10:38.134 not actually storing all the memory of the variable here in
00:10:38.134 --> 00:10:41.910 the variable called path. There's storing the address of
00:10:41.910 --> 00:10:46.151 that memory. They're saying I'm pointing to where the where the
00:10:46.151 --> 00:10:47.940 value of path is basically.
00:10:49.690 --> 00:10:54.170 And so when you start looking at reference types.
00:10:55.510 --> 00:10:59.070 In C#, there are a couple of ways to define them.
00:10:59.830 --> 00:11:02.760 So the one that you'll see most frequently, probably.
00:11:03.210 --> 00:11:07.480 Uh is uh. We'll do like a sample model, right?
00:11:09.050 --> 00:11:12.688 So cool. We've got a sample model. This is a very basic
00:11:12.688 --> 00:11:16.650 class. Well, I'd like a an ID property to it. Why not cool a
00:11:16.650 --> 00:11:20.548 simple basic class? This is obviously it's a reference type
00:11:20.548 --> 00:11:24.445 because it's not. It's not an Ant, it has an Ant, but it is
00:11:24.445 --> 00:11:25.160 not an end.
00:11:26.770 --> 00:11:28.550 And so I'm gonna make like a.
00:11:31.580 --> 00:11:32.590 Stuff.
00:11:34.280 --> 00:11:36.110 Test so.
00:11:36.580 --> 00:11:37.500 Uh.
00:11:39.540 --> 00:11:43.386 In this scenario, I can I can create an instance of a sample
00:11:43.386 --> 00:11:45.530 model. I can new IT up like this.
00:11:46.130 --> 00:11:46.730 Uh.
00:11:47.740 --> 00:11:51.390 Unfortunately, I wish it did, but C# doesn't have cool syntax
00:11:51.390 --> 00:11:55.100 like TypeScript where you can do stuff like like. You can just
00:11:55.100 --> 00:11:58.868 define like this. It's a little bit more convoluted in C# where
00:11:58.868 --> 00:12:00.340 you have to do like this.
00:12:03.300 --> 00:12:05.360 Let's see, that's not a semi colon.
00:12:07.140 --> 00:12:10.437 So you can still do that sort of inline declaration, but the, but
00:12:10.437 --> 00:12:13.534 you can't do. It's not quite as clean or cool, and there's no
00:12:13.534 --> 00:12:16.431 spread or whatever, which I I really wish C# had a spread
00:12:16.431 --> 00:12:17.930 operator. It would be so nice.
00:12:18.450 --> 00:12:23.020 Dude, I wanted it literally today. Like if you hours ago.
00:12:18.600 --> 00:12:19.160 Umm.
00:12:21.490 --> 00:12:24.520 The closest you can get is you can do like.
00:12:26.140 --> 00:12:30.630 Am I doing? You can do a shallow clone.
00:12:32.420 --> 00:12:35.473 I'm trying to remember what the method is called, but it gets
00:12:35.473 --> 00:12:37.590 lost in all the stupid service stack crap.
00:12:38.300 --> 00:12:41.810 Ask me how I feel about service deck. It's great. I love it.
00:12:41.710 --> 00:12:41.980 Yep.
00:12:43.590 --> 00:12:51.464 I don't love it. Uh anyway, uh. There used to be an easy ish
00:12:51.464 --> 00:12:51.980 way.
00:12:52.680 --> 00:12:54.370 To like.
00:12:56.110 --> 00:12:59.398 Shallow clone and object and then you could reassign values
00:12:59.398 --> 00:13:01.480 and stuff, which is effectively what.
00:13:03.100 --> 00:13:05.750 The spread operator does. It's a shallow cloning operation.
00:13:06.770 --> 00:13:08.080 Umm. But anyway.
00:13:09.070 --> 00:13:13.280 Uh, so yeah, I can. I can do this up because this is a class.
00:13:13.920 --> 00:13:17.570 OK, so now interfaces are the other half of this.
00:13:23.050 --> 00:13:27.314 An interface is exactly that. It defines the interface for
00:13:27.314 --> 00:13:31.000 communicating with some some kind of sample model.
00:13:32.090 --> 00:13:36.947 Interfaces in and of themselves are not valid types. They're
00:13:36.947 --> 00:13:41.007 merely a. They basically represent a contract that
00:13:41.007 --> 00:13:45.785 something that implements this interface has to fulfill. So
00:13:45.785 --> 00:13:50.562 let's give it a string called name, right? If I derive this
00:13:50.562 --> 00:13:55.180 from I sample model, meaning that the sample model class.
00:13:56.090 --> 00:14:00.249 Uh promises to fulfill all the obligations that I sample model
00:14:00.249 --> 00:14:04.540 imposes. I'm gonna get an error now because it tells me my class
00:14:04.540 --> 00:14:08.634 doesn't have name and name is part of sample model, so it has
00:14:08.634 --> 00:14:09.360 to have it.
00:14:10.410 --> 00:14:12.220 So if I go down here and add public.
00:14:12.940 --> 00:14:14.380 String name.
00:14:15.790 --> 00:14:16.700 Mayor will go away.
00:14:18.160 --> 00:14:21.140 Now what that also means is because this is basically just.
00:14:22.160 --> 00:14:26.783 A. A contract to fulfill. I can't new up an eye sample model
00:14:26.783 --> 00:14:31.179 because this isn't a real thing. This is basically just a
00:14:31.179 --> 00:14:34.590 guideline for classes which are real things.
00:14:36.930 --> 00:14:41.544 Now there are a lot of places in Seth where interfaces are used,
00:14:41.544 --> 00:14:46.158 where they really don't need to be, but there are a lot of valid
00:14:46.158 --> 00:14:50.702 uses for interfaces. One of the places in CEF you'll really see
00:14:50.702 --> 00:14:54.890 interfaces used a lot, and a place that it makes sense is.
00:14:56.070 --> 00:15:00.543 Providers. So let's I'm gonna keep my little uh stuff class
00:15:00.543 --> 00:15:05.090 for testing, just to kind of keep a scratch pad. But you can
00:15:04.330 --> 00:15:04.920 Sorry to.
00:15:05.090 --> 00:15:05.910 have, yeah.
00:15:05.870 --> 00:15:09.015 So I interrupt again, but Alex did he? Did he actually answer
00:15:09.015 --> 00:15:12.059 your question yet? Because I feel like he got a little more
00:15:12.059 --> 00:15:15.256 like in the weeds and like, did he answer five and six and all
00:15:15.256 --> 00:15:15.560 those?
00:15:16.550 --> 00:15:20.024 No, I think he's getting to it. And this is actually a really
00:15:18.450 --> 00:15:18.760 OK.
00:15:20.024 --> 00:15:23.553 good flow. I'm glad that you're going through it this way. The
00:15:22.440 --> 00:15:23.340 Yeah, I.
00:15:22.630 --> 00:15:22.900 OK.
00:15:23.553 --> 00:15:27.083 the big take away that I got is like that the folder structure
00:15:27.083 --> 00:15:30.444 is dependent from like top to bottom. So things in like the
00:15:29.080 --> 00:15:29.470 Right.
00:15:30.444 --> 00:15:33.470 override layer, they're dependent on things that come
00:15:32.910 --> 00:15:34.040 Above it, yeah.
00:15:33.470 --> 00:15:34.310 before it. Yep.
00:15:34.780 --> 00:15:37.599 Yeah, everything below depends on everything above. Sort of
00:15:35.170 --> 00:15:35.490 That.
00:15:35.250 --> 00:15:35.550 OK.
00:15:37.599 --> 00:15:40.607 kind of there's there's a little bit of asterisk there and it's
00:15:40.607 --> 00:15:43.614 not too big of a deal. It's not, it's not enough of an asterisk
00:15:43.614 --> 00:15:46.433 that it matters really, unless you're getting really in the
00:15:46.433 --> 00:15:46.950 weeds, but.
00:15:47.850 --> 00:15:48.100 Good.
00:15:49.230 --> 00:15:51.975 But yeah, I'll I'll go through each layer a little bit more,
00:15:51.975 --> 00:15:54.585 but the the registry loader and all the like class versus
00:15:54.585 --> 00:15:57.375 interface stuff I think is like it's kind of a sticking point
00:15:57.375 --> 00:15:59.850 for a lot of people that it it it's very confusing. So
00:15:58.280 --> 00:15:58.730 Mm-hmm.
00:15:59.850 --> 00:16:02.730 apologies if I kind of derailed, but I'm I was gonna cover that
00:16:00.920 --> 00:16:01.570 Yeah, I.
00:16:02.730 --> 00:16:05.070 real quick and then keep moving through the layers.
00:16:03.490 --> 00:16:03.790 Yeah.
00:16:05.590 --> 00:16:08.584 I just didn't want you to end up not going through them because
00:16:07.940 --> 00:16:12.342 Yep, Yep. Good. Good call. Yeah, keep me. Keep me on topic, but
00:16:08.584 --> 00:16:11.250 you went through so much other stuff, you know, so yeah.
00:16:12.342 --> 00:16:16.332 yeah, I'll, I'll finish this point up. But anyway. So the
00:16:16.332 --> 00:16:17.570 idea there, let's.
00:16:19.170 --> 00:16:24.211 Uh I shipping provider, right? So we have an interface that
00:16:24.211 --> 00:16:29.167 says that shipping providers are mandated. Everything that
00:16:29.167 --> 00:16:34.208 implements I shipping provider is mandated to have a method
00:16:34.208 --> 00:16:36.140 that returns a list of.
00:16:37.050 --> 00:16:40.640 Uh rake quote models, let's call it get rate quotes.
00:16:42.140 --> 00:16:45.070 And it requires I don't know, and a card ID or something.
00:16:45.750 --> 00:16:46.410 UM.
00:16:48.970 --> 00:16:52.710 So just to ask a very basic question, what you just typed
00:16:49.440 --> 00:16:49.860 Ohh.
00:16:52.710 --> 00:16:56.837 out there that list that that's actually what is being returned
00:16:54.690 --> 00:16:54.980 Uh-huh.
00:16:56.837 --> 00:16:58.900 by the git rate quotes function.
00:16:58.250 --> 00:17:03.066 Correct. Yeah, yes. So C# does things kind of backwards
00:17:03.066 --> 00:17:08.656 compared to to TypeScript where the the format for a variable is
00:17:08.656 --> 00:17:09.860 type and name.
00:17:10.530 --> 00:17:14.946 And the type in C# is always required. C# is considered a
00:17:14.946 --> 00:17:19.819 strongly typed language, which means that there's no such thing
00:17:19.819 --> 00:17:21.570 as a typeless variable.
00:17:22.730 --> 00:17:26.139 There are variables who have a type generic enough that
00:17:26.139 --> 00:17:29.973 theoretically anything can be assigned to them, but using that
00:17:29.973 --> 00:17:31.130 type is considered.
00:17:31.860 --> 00:17:35.753 Bad practice most of the time because it indicates that you're
00:17:35.753 --> 00:17:38.040 not using the type system correctly.
00:17:39.490 --> 00:17:42.802 If you're ever curious by the way, the type that can have
00:17:42.802 --> 00:17:45.600 anything assigned to it is object question mark.
00:17:46.340 --> 00:17:50.080 Umm, this type is basically the same as like any in TypeScript.
00:17:53.080 --> 00:17:56.902 That being said, you can't new up. I mean I you I guess you can
00:17:56.902 --> 00:18:00.068 new up objects, but it's a completely like senseless
00:18:00.068 --> 00:18:01.740 operation. It means nothing.
00:18:03.200 --> 00:18:08.128 Because similarly to uh to other strongly typed languages, and
00:18:08.128 --> 00:18:13.290 unlike TypeScript or JavaScript, the properties on an object are.
00:18:14.000 --> 00:18:18.160 Are absolute and non-negotiable if you will. So what that means
00:18:18.160 --> 00:18:18.940 is that, uh.
00:18:20.690 --> 00:18:22.020 Real quick, I'll just make that like.
00:18:24.290 --> 00:18:24.990 Model.
00:18:26.380 --> 00:18:28.730 Uh, public and ID again, right?
00:18:29.590 --> 00:18:34.113 This class has an ID property. It only has an ID property. It
00:18:34.113 --> 00:18:37.760 has to have an ID property. You can you can like.
00:18:38.550 --> 00:18:39.370 Knew this up.
00:18:40.460 --> 00:18:44.368 And theoretically not set ID to anything but ID. Still in here
00:18:44.368 --> 00:18:47.780 it gets set to its default value for an int it's zero.
00:18:48.320 --> 00:18:53.116 Umm. But either way this will always have an ID and I can't do
00:18:53.116 --> 00:18:57.303 stuff like sample dot name equals something because it
00:18:57.303 --> 00:19:02.252 doesn't have a name property and C also doesn't have the concept
00:19:02.252 --> 00:19:02.480 of.
00:19:03.140 --> 00:19:04.430 Like uh.
00:19:05.500 --> 00:19:08.710 Property accessing via something like this UM.
00:19:10.360 --> 00:19:14.559 So the the properties that are all that are defined on an
00:19:14.559 --> 00:19:17.020 object are always on that object.
00:19:18.660 --> 00:19:23.257 And it's it's basically that a types our concrete and immutable
00:19:23.257 --> 00:19:26.490 at runtime they they just are what they are.
00:19:28.460 --> 00:19:28.850 So.
00:19:29.720 --> 00:19:32.663 Again, sorry a little bit of a detour, but yeah, so like I was
00:19:32.663 --> 00:19:32.990 saying.
00:19:34.190 --> 00:19:36.844 It's a little bit backwards since sharp compared to
00:19:36.844 --> 00:19:40.060 TypeScript. You have to define type, then variable name and in
00:19:40.060 --> 00:19:43.326 the case of methods that works, the same way return type method
00:19:43.326 --> 00:19:46.593 name and the new parentheses and the arguments that go into the
00:19:46.593 --> 00:19:49.706 method. So when you're reading one of these you're gonna see
00:19:49.706 --> 00:19:52.820 some wacky stuff like override or async or whatever. You can
00:19:52.820 --> 00:19:56.188 kind of ignore everything before this, you might see stuff that's
00:19:56.188 --> 00:19:59.200 like public static or whatever. Ultimately, the thing that
00:19:59.200 --> 00:20:02.466 matters to you is whatever comes immediately before the name so
00:20:02.466 --> 00:20:03.130 in this case.
00:20:03.330 --> 00:20:06.353 There's a method here called check can't handle file and it
00:20:06.353 --> 00:20:07.260 returns a Boolean.
00:20:07.850 --> 00:20:11.553 Umm, there's a method here called parse to sheet async and
00:20:11.553 --> 00:20:15.383 it returns a task of import sheet which I'll try to see if I
00:20:15.383 --> 00:20:19.463 can cover async await stuff in C it's very similar to TypeScript
00:20:19.463 --> 00:20:23.292 so it's not really all that complicated but I'll put that in
00:20:23.292 --> 00:20:27.309 the back of my mind for later. So back to this whole interfaces
00:20:27.309 --> 00:20:30.887 thing. The reason that this makes sense. The reason that
00:20:30.887 --> 00:20:34.654 this has value is because in theory there could be multiple
00:20:34.654 --> 00:20:37.290 shipping providers, so for example FedEx.
00:20:37.560 --> 00:20:41.529 Shipping is an eye shipping provider, right? And it has to
00:20:41.529 --> 00:20:45.499 implement get rate quotes because it says it will. It says
00:20:45.499 --> 00:20:47.450 I am and I shipping provider.
00:20:48.530 --> 00:20:54.708 So now it's gonna, you know, go send a request to FedEx with the
00:20:54.708 --> 00:20:59.460 stuff, the cart info or whatever and then return.
00:21:00.340 --> 00:21:00.880 Uh.
00:21:01.880 --> 00:21:05.213 Just so that this stops having an error returned, its rate
00:21:05.213 --> 00:21:08.433 quotes and then same deal over here. Public class uh UPS
00:21:08.433 --> 00:21:10.580 shipping from an I shipping provider.
00:21:11.700 --> 00:21:16.110 Same deal, it goes and sends a request to UPS instead of FedEx
00:21:16.110 --> 00:21:16.810 obviously.
00:21:18.850 --> 00:21:22.403 And gets back the rate quotes and returns them at the end of
00:21:22.403 --> 00:21:25.782 the day code that's using a shipping provider, it doesn't
00:21:25.782 --> 00:21:29.218 need to know or care if it's FedEx, UPS, or anything else.
00:21:29.218 --> 00:21:32.655 All it cares about is that it needs to be able to get rate
00:21:32.655 --> 00:21:36.441 quotes right? So you could write a method here that accepts an I
00:21:36.441 --> 00:21:37.490 shipping provider.
00:21:38.330 --> 00:21:43.120 And while this as a type in and of itself isn't valid.
00:21:44.290 --> 00:21:47.106 Variables of type UPS shipping or FedEx Shipping can be
00:21:47.106 --> 00:21:50.425 assigned to a variable of type I shipping provider. So that means
00:21:50.425 --> 00:21:53.040 that I could do something like I shipping provider.
00:21:53.620 --> 00:21:58.134 Uh sample equals new UPS shipping. This is valid because
00:21:58.134 --> 00:22:03.045 a UPS shipping provider is an I shipping provider. Because of
00:22:03.045 --> 00:22:07.480 this implementation. Because of this relationship here.
00:22:08.900 --> 00:22:11.759 However, you can't do eye shipping provider because that's
00:22:11.759 --> 00:22:14.861 not. That's not specific enough and I forget exactly what error
00:22:14.861 --> 00:22:15.830 it'll tell you, but.
00:22:16.490 --> 00:22:19.415 Of course, there appeared and then promptly went away.
00:22:19.415 --> 00:22:19.840 Classic.
00:22:21.060 --> 00:22:25.077 That's just Intellisense being dumped. There is an error here.
00:22:25.077 --> 00:22:28.966 This will not build. UM, but anyway, the value for that is I
00:22:28.966 --> 00:22:32.728 don't have to care about UPS versus FedEx versus whatever.
00:22:32.728 --> 00:22:36.745 All I care about is I shipping provider and then in here I can
00:22:36.745 --> 00:22:40.698 save our right quotes equals provider dot get rate quotes and
00:22:40.698 --> 00:22:44.651 it doesn't matter what does this crying about. Yeah. Card ID?
00:22:44.651 --> 00:22:44.970 Sure.
00:22:45.450 --> 00:22:48.708 Umm, it doesn't matter if this is UPS, FedEx, whatever. I'm
00:22:48.708 --> 00:22:52.184 just gonna get back my list of right quotes and then I can, you
00:22:52.184 --> 00:22:54.410 know, do whatever I need to do for each.
00:22:55.190 --> 00:22:57.010 Great quote and rate quotes and.
00:22:58.600 --> 00:23:01.295 I sure wish my hands worked to day. There we go. I can do
00:23:01.295 --> 00:23:04.269 whatever I want with these rate quotes and I don't have to care
00:23:04.269 --> 00:23:07.011 if they came from FedEx, UPS, whatever, some custom logic,
00:23:07.011 --> 00:23:08.080 some other third party.
00:23:08.760 --> 00:23:09.460 UM.
00:23:10.150 --> 00:23:13.446 Anything like that. And so that's the value with these
00:23:13.446 --> 00:23:17.042 interfaces. And finally to to wrap it all up in a nice neat
00:23:17.042 --> 00:23:18.960 little bow, the registry loader.
00:23:20.460 --> 00:23:26.373 Maps interfaces like I shipping provider to implementations like
00:23:26.373 --> 00:23:27.920 FedEx and UPS so.
00:23:29.160 --> 00:23:32.731 Our code just has to say I need a shipping provider and the
00:23:32.731 --> 00:23:36.541 registry loader is the one that says OK well, according to your
00:23:36.541 --> 00:23:40.410 app settings and any other logic that's been implemented. I know
00:23:40.410 --> 00:23:43.922 that when you say you want an I shipping provider for this
00:23:43.922 --> 00:23:47.375 instance of CEF you want UPS, FedEx and flat rate because
00:23:47.375 --> 00:23:51.125 that's what you have enabled in your app settings and it gives
00:23:51.125 --> 00:23:52.970 you back those implementations.
00:23:53.620 --> 00:23:56.811 Umm. And then you know, same thing with like payment
00:23:56.811 --> 00:24:00.724 providers, inventory providers, pricing, all that kind of stuff.
00:24:00.724 --> 00:24:04.457 There's an interface for all of those. And then there's logic
00:24:04.457 --> 00:24:08.311 inside the registry loader that knows when you ask for whatever
00:24:08.311 --> 00:24:11.983 kind of provider that is using the settings it knows to give
00:24:11.983 --> 00:24:13.910 you back FedEx, UPS or whatever.
00:24:15.040 --> 00:24:17.830 So that is what the registry loader does.
00:24:18.960 --> 00:24:24.186 And you'll use it anytime you need to get at the provider that
00:24:24.186 --> 00:24:28.996 you're trying to use, or additionally get at the database
00:24:28.996 --> 00:24:29.660 context.
00:24:30.640 --> 00:24:33.230 Which moves us nicely into.
00:24:35.770 --> 00:24:38.670 The next thing the data access layer.
00:24:40.780 --> 00:24:44.774 So before I move too much further, do you guys have any
00:24:44.774 --> 00:24:49.482 questions on anything in here or any kind of general C# topics or
00:24:49.482 --> 00:24:51.550 anything like that before we?
00:24:52.590 --> 00:24:54.600 Before we start digging in a little bit further.
00:24:57.100 --> 00:25:01.246 Just the poke at that function on 20-30. How asynchronous is
00:25:01.246 --> 00:25:01.450 it?
00:25:02.770 --> 00:25:07.101 This one actually, surprisingly or not surprisingly, this is not
00:25:07.101 --> 00:25:10.100 async, but it still returns a task. This is.
00:25:11.060 --> 00:25:11.340 And.
00:25:14.150 --> 00:25:14.760 And then.
00:25:15.820 --> 00:25:17.850 And they like.
00:25:19.800 --> 00:25:24.930 The same as promise resolve in in JavaScript or TypeScript.
00:25:27.200 --> 00:25:31.192 Uh, you can also, if you're if you return just a task that
00:25:31.192 --> 00:25:35.185 doesn't have any sort of return type, you can use task dot
00:25:35.185 --> 00:25:36.200 completed task.
00:25:37.100 --> 00:25:41.042 Which is the same as promised dot resolve with no argument
00:25:41.042 --> 00:25:41.710 passed in.
00:25:42.370 --> 00:25:43.880 Uh, so?
00:25:45.070 --> 00:25:51.364 Task is a is a relatively close analog to promise in JavaScript
00:25:51.364 --> 00:25:57.265 and TypeScript. The only the only significant difference to
00:25:57.265 --> 00:25:59.920 task versus Promise Inc is.
00:26:01.070 --> 00:26:05.171 With promises in TypeScript, it's relatively normal behavior
00:26:05.171 --> 00:26:05.910 to do like.
00:26:06.510 --> 00:26:12.512 Umm some from this method dot then and then use your use your
00:26:12.512 --> 00:26:17.740 results in the body that is not common practice in C.
00:26:20.260 --> 00:26:24.529 Technically it's possible, but I it nowhere in CEF does that, and
00:26:24.529 --> 00:26:28.216 generally speaking it it, it's messier code and you guys
00:26:28.216 --> 00:26:29.510 probably all prefer.
00:26:30.400 --> 00:26:33.993 Async await for the most part syntactically, at least in in
00:26:33.993 --> 00:26:37.705 JavaScript because you know it's way less nesting. It's a lot
00:26:37.705 --> 00:26:41.597 easier to read all that kind of stuff. Well, C# is the same way.
00:26:41.597 --> 00:26:45.309 Technically you can do that, but over here it's substantially
00:26:45.309 --> 00:26:48.961 less common to do the way that we do sometimes in TypeScript
00:26:48.961 --> 00:26:52.734 with the. Then you'll just await those calls. So anything that
00:26:52.734 --> 00:26:54.530 returns a task can be awaited.
00:26:55.250 --> 00:26:55.710 Umm.
00:26:57.160 --> 00:27:00.987 And while I'm thinking about it, that's gonna lead to something
00:27:00.987 --> 00:27:04.516 you guys will have almost definitely seen. UM. And I wanna
00:27:04.516 --> 00:27:06.370 try to find a good spot for it.
00:27:11.270 --> 00:27:11.750 That'll work.
00:27:14.150 --> 00:27:18.910 So get file save path async returns a task of string.
00:27:19.640 --> 00:27:24.000 When I await that it sheds the task and returns to me just a
00:27:24.000 --> 00:27:26.430 string. Ignore the question mark.
00:27:27.700 --> 00:27:29.810 I'll talk about that in a bit, but.
00:27:31.950 --> 00:27:35.780 Something that you've definitely seen is this business here.
00:27:36.360 --> 00:27:38.270 Umm in.
00:27:39.730 --> 00:27:44.603 In C#, I I don't fully understand exactly what the
00:27:44.603 --> 00:27:47.660 problem here is, but in essence.
00:27:48.470 --> 00:27:54.652 We're on an old version of net using an old framework of
00:27:54.652 --> 00:27:55.520 asp.net.
00:27:56.060 --> 00:28:02.035 Umm. And as a result, due to some weird design decisions they
00:28:02.035 --> 00:28:03.770 made 20 years ago.
00:28:04.780 --> 00:28:08.533 If you forget this, configure await false when you await a
00:28:08.533 --> 00:28:11.840 task, there's a small chance that it will deadlock.
00:28:12.840 --> 00:28:16.944 So it's just hard locks the entire application and you know
00:28:16.944 --> 00:28:20.980 that's obviously not good. So that's why we're we're very.
00:28:22.030 --> 00:28:25.290 Uh, we're very hard on PR's that forget this is because.
00:28:25.950 --> 00:28:29.583 You know it's it matters. It's not just like a personal like
00:28:29.583 --> 00:28:33.156 preference type of thing. This little configure await false
00:28:33.156 --> 00:28:35.360 thing is very important to remember.
00:28:39.240 --> 00:28:40.650 So. Umm.
00:28:42.370 --> 00:28:45.590 Uh, yeah, generally speaking as well, you'll note that any
00:28:45.590 --> 00:28:49.028 method that has an any method that has an async suffix returns
00:28:49.028 --> 00:28:49.410 a task.
00:28:50.800 --> 00:28:54.671 And vice versa, any method that returns a task should have an
00:28:54.671 --> 00:28:58.730 async suffix, because it's. It's just a clear and concise way to
00:28:58.730 --> 00:29:02.601 communicate to you that you need to await this. The result of
00:29:02.601 --> 00:29:03.350 this method.
00:29:06.260 --> 00:29:10.413 So that being said, much like much like TypeScript, you can
00:29:10.413 --> 00:29:12.490 choose not to await something.
00:29:13.800 --> 00:29:16.510 There's not really a good reason not to, but you could say like.
00:29:17.040 --> 00:29:20.170 Uh file path task equals just this.
00:29:20.930 --> 00:29:24.125 You now have an instance of the task. We didn't await it, so we
00:29:24.125 --> 00:29:27.320 didn't shed task. We just have a task of string, right and then
00:29:27.320 --> 00:29:27.620 later.
00:29:28.340 --> 00:29:33.339 Do some whatevers later. I can then do import file root path
00:29:33.339 --> 00:29:34.650 equals a weight.
00:29:35.310 --> 00:29:38.950 File path task and of course don't forget your configure way
00:29:38.950 --> 00:29:40.800 false. This is perfectly valid.
00:29:41.510 --> 00:29:45.084 It's not really going to happen anywhere. Nobody does this.
00:29:45.084 --> 00:29:48.360 There's not really a reason to, but you certainly can.
00:29:49.000 --> 00:29:49.620 Umm.
00:29:52.070 --> 00:29:54.260 Uh, trying to think.
00:29:55.360 --> 00:29:57.910 I hope that answers your question.
00:29:55.450 --> 00:29:56.090 OK.
00:29:58.330 --> 00:30:02.412 Yeah, that thing pretty much is asynchronous. We just don't see
00:30:02.412 --> 00:30:06.174 it being asynchronous whenever it's being declared on that
00:30:06.174 --> 00:30:09.809 other file, it it's being awaited here. So eventually it
00:30:07.390 --> 00:30:08.160 Right. So.
00:30:09.420 --> 00:30:10.090 Correct.
00:30:09.809 --> 00:30:11.340 it is asynchronous cool.
00:30:11.680 --> 00:30:15.754 Well, it's a bit hard to explain because like in in here it
00:30:15.754 --> 00:30:19.150 returns a task, so it must have the async suffix.
00:30:19.910 --> 00:30:23.381 However, this method isn't awaiting anything, so it doesn't
00:30:23.381 --> 00:30:26.967 need to be considered async. If I you could make it say async
00:30:26.967 --> 00:30:30.496 here and it'll tell you this method lacks async, lacks await
00:30:30.496 --> 00:30:33.330 operators. Consider using the await or whatever.
00:30:35.440 --> 00:30:38.997 Theoretically it's not needed, and so then what I can do is if
00:30:38.997 --> 00:30:42.442 I don't need to await anything, I can still have it returned
00:30:42.442 --> 00:30:44.870 task as it's required to by the interface.
00:30:46.640 --> 00:30:50.591 But instead of returning straight out, I can return a
00:30:50.591 --> 00:30:54.542 task that contains the result and that satisfies this
00:30:54.542 --> 00:30:55.420 requirement.
00:30:56.240 --> 00:30:56.900 Umm.
00:30:58.570 --> 00:31:01.550 Rather than having it do UM.
00:31:02.710 --> 00:31:03.010 Like.
00:31:03.820 --> 00:31:07.093 Having it warned me that I don't have any awaits in an async
00:31:07.093 --> 00:31:10.365 method, which doesn't really matter, it's just a style thing
00:31:10.365 --> 00:31:10.580 but.
00:31:11.050 --> 00:31:14.517 Umm but yeah, just because of method returns a task doesn't
00:31:14.517 --> 00:31:17.811 mean it has to be an async method. It just means that it
00:31:17.811 --> 00:31:21.510 can be an async method and when it returns a task, the task has
00:31:21.510 --> 00:31:23.590 to be a weighted to get the result.
00:31:24.810 --> 00:31:25.660 Does that make sense?
00:31:26.920 --> 00:31:27.650 Yeah.
00:31:27.950 --> 00:31:30.979 It's and it's a little bit kind of goofy that it's like a
00:31:30.979 --> 00:31:33.120 relationships not exactly 1 to one, but.
00:31:34.380 --> 00:31:37.944 You you can treat it as though it were. So if you're calling
00:31:37.944 --> 00:31:41.507 any method that has async in the name, just know you need to
00:31:41.507 --> 00:31:44.720 await it and when you await anything, don't forget it.
00:31:44.720 --> 00:31:46.590 Configure await false somewhere.
00:31:48.420 --> 00:31:49.760 Made points here OK.
00:31:48.980 --> 00:31:52.564 So yeah, so that's that's kind of the big you know the the most
00:31:52.564 --> 00:31:53.460 important stuff.
00:31:54.250 --> 00:31:54.830 Umm.
00:31:56.420 --> 00:32:00.469 OK, so the registry loaded by the way is also the reason for
00:32:00.469 --> 00:32:04.585 the context profile name that you guys have probably seen the
00:32:04.585 --> 00:32:08.833 mentally a million places. Every method takes a context profile
00:32:08.833 --> 00:32:11.090 name as a string reason for that.
00:32:13.020 --> 00:32:16.861 Is it's related to our unit test, but basically every unit
00:32:16.861 --> 00:32:20.637 test has a unique context profile name. I don't know what
00:32:20.637 --> 00:32:24.673 that name. I don't know what context profile name means, it's
00:32:24.673 --> 00:32:28.840 just that I know that every unit test has a unique one and that
00:32:28.840 --> 00:32:32.680 name identifies a container in the registry loader so that
00:32:32.680 --> 00:32:35.805 everything is uniquely identified. Basically at
00:32:35.805 --> 00:32:39.646 runtime, like when you're running on your local and you're
00:32:39.646 --> 00:32:41.990 not running unit tests or whatever.
00:32:42.400 --> 00:32:44.440 Context profile name is always null.
00:32:45.000 --> 00:32:50.261 Umm, that being said, never explicitly pass null for this
00:32:50.261 --> 00:32:51.350 always pass.
00:32:52.260 --> 00:32:55.125 Whatever you can get it from, you know, typically it's passed
00:32:55.125 --> 00:32:57.991 into the method you're already in, like 99% of the time. It's
00:32:57.991 --> 00:32:59.100 just kind of everywhere.
00:33:00.300 --> 00:33:01.160 But if you need it.
00:33:01.830 --> 00:33:05.105 That would be where you'd get it, as you'd pass it down. If
00:33:05.105 --> 00:33:08.217 you're in an an endpoint handler, which we'll talk about
00:33:08.217 --> 00:33:11.329 those in a bit, then you have access to this one service
00:33:11.329 --> 00:33:14.495 context profile name, which if we go click on it, it just
00:33:14.495 --> 00:33:15.150 equals null.
00:33:16.360 --> 00:33:16.730 But.
00:33:18.210 --> 00:33:18.660 Umm.
00:33:20.040 --> 00:33:23.206 Yeah, if you ever pass something non null for this on your local
00:33:23.206 --> 00:33:24.180 it will break stuff.
00:33:26.440 --> 00:33:29.883 Like if you if you don't pass whatever it's supposed to be
00:33:29.883 --> 00:33:33.384 based on either service context profile name coming from an
00:33:33.384 --> 00:33:36.944 endpoint or context profile name being passed in from a unit
00:33:36.944 --> 00:33:40.620 test, then you're either gonna have test failing or your local
00:33:40.620 --> 00:33:44.297 like your site just won't work when you run it and or both. So
00:33:44.297 --> 00:33:47.623 just keep in mind that if context profile name is passed
00:33:47.623 --> 00:33:48.440 into a method.
00:33:49.160 --> 00:33:52.057 And then you have another method that asks for context profile
00:33:52.057 --> 00:33:53.850 name. Just keep passing it on through.
00:33:56.220 --> 00:33:59.671 It's unfortunate that we have to, but that is that is how it
00:33:59.671 --> 00:34:00.010 works.
00:34:02.730 --> 00:34:06.323 So OK, so moving on to data access layer and I'll probably
00:34:06.323 --> 00:34:10.342 start to go some of these layers will go really fast, but I wanna
00:34:10.342 --> 00:34:13.630 try to make sure I can cover as much of it as we can.
00:34:14.050 --> 00:34:17.600 Umm the data access layer is kind of the next level, so where
00:34:17.600 --> 00:34:20.979 the core is all shared things that everything down here is
00:34:20.979 --> 00:34:24.529 gonna reference the data access layer is the first thing that
00:34:24.529 --> 00:34:27.736 depends on some of this. Obviously it's going to depend
00:34:27.736 --> 00:34:31.229 on like configuration. It's gonna depend on registry loader,
00:34:31.229 --> 00:34:34.550 all that kind of stuff. And so to that end the data model
00:34:34.550 --> 00:34:38.158 obviously is database interrupt. So this is the layer. This is
00:34:38.158 --> 00:34:41.365 all the code that handles communicating with the actual
00:34:41.365 --> 00:34:41.880 database.
00:34:42.560 --> 00:34:43.170 UM.
00:34:44.200 --> 00:34:52.833 Now we use a a tool called Entity framework to simplify
00:34:52.833 --> 00:34:53.450 our.
00:34:53.900 --> 00:34:54.680 Uh.
00:34:55.700 --> 00:35:00.935 Our database code, so instead of having to go physically write
00:35:00.935 --> 00:35:06.336 SQL that does everything, we use entity framework to allow us to
00:35:06.336 --> 00:35:10.990 query and write and read from the database in Native C.
00:35:11.750 --> 00:35:16.890 UM and it handles compiling or transpiling that to SQL.
00:35:17.550 --> 00:35:20.829 And doing all the communication with the database for us. So it
00:35:20.829 --> 00:35:23.749 makes our job easier as developers because we don't have
00:35:23.749 --> 00:35:26.670 to maintain two different languages inside the same code
00:35:26.670 --> 00:35:29.180 base. We can just write C# and get what we need.
00:35:30.800 --> 00:35:34.410 And any framework is a Microsoft product, which means that it has
00:35:34.410 --> 00:35:35.230 some funkiness.
00:35:36.670 --> 00:35:37.110 But.
00:35:37.190 --> 00:35:41.577 The the basic terminology when you're working with entity
00:35:41.577 --> 00:35:42.560 framework is.
00:35:43.290 --> 00:35:45.630 Database context and.
00:35:46.420 --> 00:35:46.820 Entity.
00:35:47.140 --> 00:35:51.277 Umm so an entity is a class that represents a table in the
00:35:51.277 --> 00:35:55.205 database. So for example all opened up my database real
00:35:55.205 --> 00:35:59.763 quick, but you guys are familiar with basic tables like products
00:35:59.763 --> 00:36:03.690 dot product, contacts dot user, all that kind of stuff.
00:36:05.270 --> 00:36:09.057 All of those tables actually correspond to and. I'll go look
00:36:09.057 --> 00:36:12.969 at PCs because it's the easiest. That's what I'm looking at in
00:36:12.969 --> 00:36:16.260 the code over here, and it's the latest set version.
00:36:17.700 --> 00:36:21.494 So we'll look at, I'm trying to find one that's not overly
00:36:21.494 --> 00:36:24.260 complicated, but not overly simple either.
00:36:25.200 --> 00:36:30.296 Let's let's do category. It's complicated, but not horrid. So
00:36:30.296 --> 00:36:35.227 categories dot category perfect. Let's open up the columns.
00:36:35.227 --> 00:36:40.322 Here's all the columns on the categories. That category table
00:36:40.322 --> 00:36:43.610 in the database. These all map exactly.
00:36:44.260 --> 00:36:45.500 From this models folder.
00:36:46.170 --> 00:36:51.132 Categories category open this file up and wouldn't you know
00:36:51.132 --> 00:36:51.380 it?
00:36:52.340 --> 00:36:53.910 All those properties.
00:36:54.910 --> 00:36:58.876 Are here between this file and its parent file I nameable base
00:36:58.876 --> 00:37:02.527 which has like ID custom key, created date, name, display
00:37:02.527 --> 00:37:06.052 name, all that stuff that's coming off of Nameable base
00:37:06.052 --> 00:37:09.640 which you don't really need to worry about too much but.
00:37:09.960 --> 00:37:14.690 Uh, the the basic point is that this category class.
00:37:16.250 --> 00:37:21.164 Is an object in C# that defines this table. So if you add
00:37:21.164 --> 00:37:26.671 properties onto this class in C, you can use entity framework to
00:37:26.671 --> 00:37:31.331 generate what's called a migration, and that migration
00:37:31.331 --> 00:37:35.991 will update the database to match and it will add that
00:37:35.991 --> 00:37:39.380 property onto the table in SQL as well.
00:37:39.980 --> 00:37:44.046 Umm. And so that this is kind of the first stepping stone that
00:37:44.046 --> 00:37:47.983 allows us to interact with the database through C is we have
00:37:47.983 --> 00:37:52.243 these classes that are basically a mirror of a database table, if
00:37:52.243 --> 00:37:53.340 that makes sense.
00:37:54.670 --> 00:37:56.580 My cat scratching at the door. Give me one SEC.
00:37:58.350 --> 00:37:59.830 Morning Kitty cat.
00:37:58.480 --> 00:37:59.000 Yeah.
00:38:00.880 --> 00:38:07.310 Umm, OK. So any questions on on the entity concept?
00:38:10.380 --> 00:38:12.210 No, that was helpful.
00:38:12.680 --> 00:38:13.260 Cool.
00:38:14.660 --> 00:38:16.650 There's some. There's a lot of.
00:38:18.300 --> 00:38:21.228 Umm, I can't think of a good word for it. A lot of things you
00:38:21.228 --> 00:38:24.109 have to know when you're doing these schema changes. I'm not
00:38:24.109 --> 00:38:26.895 gonna get really into that because you guys probably won't
00:38:26.895 --> 00:38:29.918 be doing schema changes unless you get more into back end work,
00:38:29.918 --> 00:38:32.610 in which case you need. You'll need more than just this.
00:38:33.420 --> 00:38:36.760 Umm, this like mad dash of information.
00:38:37.590 --> 00:38:38.360 Umm but.
00:38:39.030 --> 00:38:39.780 Uh.
00:38:41.480 --> 00:38:44.986 Basically, there's uh, the entire set of all of these
00:38:44.986 --> 00:38:49.012 classes that define different tables and things like that. So
00:38:49.012 --> 00:38:50.960 here's like shopping dot cart.
00:38:52.220 --> 00:38:55.898 The Big Boy products dot products. Uh, which this file
00:38:55.898 --> 00:38:57.570 alone is like 1000 lines.
00:38:58.270 --> 00:39:01.911 Umm, because there's so much stuff stored on the product
00:39:01.911 --> 00:39:02.550 table but.
00:39:03.110 --> 00:39:03.900 Uh.
00:39:05.390 --> 00:39:07.580 All of these classes combined together.
00:39:08.940 --> 00:39:13.313 Are what we call the data model, hence the the project. The data
00:39:13.313 --> 00:39:14.120 model layer.
00:39:15.320 --> 00:39:19.135 All of all of the tables that will be generated are the data
00:39:19.135 --> 00:39:19.510 model.
00:39:21.290 --> 00:39:25.552 And then like I mentioned earlier, anytime the data model
00:39:25.552 --> 00:39:26.140 changes.
00:39:27.080 --> 00:39:31.059 Entity framework requires us to create what's called a migration
00:39:31.059 --> 00:39:34.915 so that we can keep our code and the files that that represent
00:39:34.915 --> 00:39:38.159 our tables In Sync with the tables themselves in the
00:39:38.159 --> 00:39:38.710 database.
00:39:41.160 --> 00:39:45.491 This approach is called code first. So what that means is
00:39:45.491 --> 00:39:49.000 that we define our database schema in C# code.
00:39:49.630 --> 00:39:53.476 And then we use entity framework to update the database, so the
00:39:53.476 --> 00:39:55.940 database follows the code IE code first.
00:39:57.830 --> 00:40:01.134 On the other direction, we don't use this way, but entity
00:40:01.134 --> 00:40:04.437 framework also allows you to do database first, where you
00:40:04.437 --> 00:40:07.399 actually go and make your changes physically on the
00:40:07.399 --> 00:40:11.158 database with whatever tools you like, and then you generate your
00:40:11.158 --> 00:40:12.810 classes based on your tables.
00:40:14.050 --> 00:40:18.080 We don't use that at clarity, but that is another option.
00:40:18.390 --> 00:40:21.591 Umm, so we use the code first option because it keeps all our
00:40:21.591 --> 00:40:24.741 code in C#. It makes it so that there's one single source of
00:40:24.741 --> 00:40:27.839 truth for everybody. Nobody's you know, if you make schema,
00:40:27.839 --> 00:40:30.782 you don't modify your local database and then go have to
00:40:30.782 --> 00:40:33.931 like upload a backup to QA or whatever. It's just you modify
00:40:33.931 --> 00:40:37.235 the code and then everybody gets a migration that updates their
00:40:37.235 --> 00:40:38.010 local for them.
00:40:39.250 --> 00:40:42.000 So a little bit more convenient for for working as a team.
00:40:42.740 --> 00:40:46.142 Uh, so like I mentioned earlier, we we've covered entities. The
00:40:46.142 --> 00:40:49.385 other major term you'll come across when you're working with
00:40:49.385 --> 00:40:51.990 entity framework is context or database context.
00:40:52.530 --> 00:40:55.475 UM Inceptive file is called clarity ecommerce entities. I
00:40:55.475 --> 00:40:58.725 don't know why it doesn't have context in it. It totally should
00:40:58.725 --> 00:41:01.823 because that's standard entity framework terminology, but it
00:41:01.823 --> 00:41:02.940 doesn't really matter.
00:41:04.460 --> 00:41:08.309 The database context is basically your your window into
00:41:08.309 --> 00:41:12.433 the database. So if you ever need to read or write anything
00:41:12.433 --> 00:41:16.351 tour from the database, a database context is how you do
00:41:16.351 --> 00:41:20.819 it. It is the actual where each class is basically the structure
00:41:20.819 --> 00:41:25.218 of a table. The context is like your connection to the database
00:41:25.218 --> 00:41:26.730 through those classes.
00:41:27.460 --> 00:41:28.040 Umm.
00:41:29.290 --> 00:41:30.800 And.
00:41:30.010 --> 00:41:32.740 To show us an example of that being used.
00:41:32.890 --> 00:41:37.487 Yep, I sure can. I'll have to, like, make a basic example
00:41:37.487 --> 00:41:38.280 somewhere.
00:41:38.940 --> 00:41:39.890 UM.
00:41:41.050 --> 00:41:44.081 Because I can't think of any nice easy places that you can
00:41:44.081 --> 00:41:45.520 clearly see what's going on.
00:41:46.120 --> 00:41:46.810 Umm.
00:41:47.860 --> 00:41:48.990 Back to the scratch pad.
00:41:50.470 --> 00:41:53.640 Uh, so we'll make our stuff again.
00:41:54.770 --> 00:41:57.639 And a method on here just so we can get, you know, ignoring all
00:41:57.639 --> 00:42:00.463 this. You know, stuff. I'm just getting to a place where I can
00:42:00.463 --> 00:42:01.180 write some code.
00:42:02.420 --> 00:42:03.110 So.
00:42:04.500 --> 00:42:08.099 In order to use the database context, you'll see this line
00:42:08.099 --> 00:42:11.821 all over the place in CEF. Using VAR context equals registry
00:42:11.821 --> 00:42:15.603 loader, wrapper dot getcontext, and we'll make this pass in a
00:42:15.603 --> 00:42:19.019 context profile name because everything does, we're not
00:42:19.019 --> 00:42:22.741 actually gonna call this, but just so you guys have an idea,
00:42:22.741 --> 00:42:26.706 you have to pass context profile name into get context. Remember
00:42:26.706 --> 00:42:30.672 I mentioned earlier the registry loader, it maps an interface to
00:42:30.672 --> 00:42:34.210 an implementation. Guess what? This returns an interface.
00:42:34.510 --> 00:42:37.245 Clarity, commerce entities and it's implementation is clarity,
00:42:37.245 --> 00:42:38.070 ecommerce entities.
00:42:38.770 --> 00:42:40.200 Umm so.
00:42:40.910 --> 00:42:44.848 This using thing is probably very weird for you guys. Uh,
00:42:44.848 --> 00:42:48.718 because to my Knowledge TypeScript has no analog to this
00:42:48.718 --> 00:42:52.520 and it's a it's a pretty uniquely C# ISH type of thing.
00:42:53.270 --> 00:42:53.930 Umm.
00:42:55.710 --> 00:43:00.498 It vaguely parallels the concept of REI from other languages.
00:43:00.498 --> 00:43:04.746 Resource acquisition is initialization which what that
00:43:04.746 --> 00:43:06.600 basically means is that.
00:43:07.950 --> 00:43:10.360 The moment that this object is created.
00:43:11.130 --> 00:43:15.432 It's it's considered an acquired resource and the moment that it
00:43:15.432 --> 00:43:18.410 is unacquired the resources should be freed.
00:43:19.130 --> 00:43:22.702 Umm, and that's exactly what this using does the database,
00:43:22.702 --> 00:43:26.092 the context, the database context that we get back here
00:43:26.092 --> 00:43:29.905 like I mentioned earlier, this is your window to the database.
00:43:29.905 --> 00:43:32.690 It has an actual connection to your database.
00:43:33.700 --> 00:43:37.388 On your local, that's probably through some cool Windows
00:43:37.388 --> 00:43:41.334 technology, and I don't you know, I don't understand at all,
00:43:41.334 --> 00:43:45.539 but if you're like connecting to the QA database from your local
00:43:45.539 --> 00:43:49.421 or something, this is an actual HTTP like, you know, actual
00:43:49.421 --> 00:43:50.650 network connection.
00:43:51.290 --> 00:43:51.920 And so.
00:43:52.850 --> 00:43:54.760 Whenever this method ends.
00:43:55.490 --> 00:43:59.549 Obviously, ignoring the using for now, the context would no
00:43:59.549 --> 00:44:03.472 longer be available for you to use, cause it falls out of
00:44:03.472 --> 00:44:07.666 scope. It's not, you're not in that method anymore, right? So
00:44:07.666 --> 00:44:11.861 let's say you do some do stuff with the context and then fall
00:44:11.861 --> 00:44:12.740 out of scope.
00:44:13.380 --> 00:44:16.210 Uh, once this context falls out of scope.
00:44:16.850 --> 00:44:18.190 The way that C# works.
00:44:19.290 --> 00:44:23.380 You know, mumbo jumbo of technical stuff basically means
00:44:23.380 --> 00:44:27.685 that this still lives and sits around in memory. It doesn't
00:44:27.685 --> 00:44:29.120 immediately go away.
00:44:29.810 --> 00:44:33.337 And when your code is running a lot, you know like in a
00:44:33.337 --> 00:44:37.116 production environment, you got thousands of people on your
00:44:37.116 --> 00:44:37.620 website.
00:44:39.260 --> 00:44:42.419 If there's a thousand of these sitting around in memory still
00:44:42.419 --> 00:44:45.527 connecting to the database, you're gonna kill your database.
00:44:45.527 --> 00:44:48.839 You're going to completely kill any throughput, and you may even
00:44:48.839 --> 00:44:51.845 hit concurrent connection limitations because you have too
00:44:51.845 --> 00:44:54.240 many things connected to the database at once.
00:44:54.930 --> 00:44:58.675 So what this using does at the beginning of this is it
00:44:58.675 --> 00:45:02.557 specifies that once this variable falls out of scope, it
00:45:02.557 --> 00:45:04.600 should be immediately removed.
00:45:06.850 --> 00:45:10.744 Only certain things can have using on them. So for example
00:45:10.744 --> 00:45:14.440 like what I was looking at earlier public class sample.
00:45:15.630 --> 00:45:19.180 You can't do like using var. Sample equals new sample because
00:45:19.180 --> 00:45:22.330 this sample class it'll tell you if you mouse over it.
00:45:23.170 --> 00:45:26.954 Type used in a using statement must be implicitly convertible
00:45:26.954 --> 00:45:27.870 to idisposable.
00:45:28.490 --> 00:45:29.150 UM.
00:45:29.970 --> 00:45:33.596 And what that means is that it has to implement I disposable
00:45:33.596 --> 00:45:36.984 just like that, which is an interface again. And look at
00:45:36.984 --> 00:45:40.610 we're back to that cool. So ignoring all the complexities of
00:45:40.610 --> 00:45:42.690 what I dispose will actually does.
00:45:44.350 --> 00:45:47.815 The main thing that you have to keep in mind is that anytime you
00:45:47.815 --> 00:45:51.120 use a database context, you have to put using in front of it.
00:45:53.120 --> 00:45:54.050 Otherwise.
00:45:54.760 --> 00:45:56.190 Problems basically.
00:45:55.770 --> 00:45:57.580 Memory late pretty much.
00:45:57.640 --> 00:46:01.160 Yeah, it's it's less a memory leak because the memory will
00:46:01.160 --> 00:46:04.560 eventually be cleared by a background process built into
00:46:04.560 --> 00:46:08.080 the into the C# runtime called the garbage collector. That
00:46:08.080 --> 00:46:11.600 memory will eventually be cleared. The problem is how long
00:46:11.600 --> 00:46:15.239 that process takes compared to how heavy your utilization is
00:46:15.239 --> 00:46:16.790 can lead to problems with.
00:46:17.390 --> 00:46:20.939 Uh, I guess if we want to think about it similarly to connect to
00:46:20.939 --> 00:46:24.215 a memory leak, it connection leak if you will, where you're
00:46:24.215 --> 00:46:27.490 still maintaining a connection to the database on an object
00:46:27.490 --> 00:46:28.910 that's not in use anymore.
00:46:29.530 --> 00:46:33.750 Umm. And in some of these scenarios I disposable type
00:46:33.750 --> 00:46:38.360 stuff like the database context. It may actually be using.
00:46:39.000 --> 00:46:39.670 Umm.
00:46:40.720 --> 00:46:44.536 Quote UN quote C# calls it unsafe memory practices where
00:46:44.536 --> 00:46:48.621 even if the garbage collector does kill it, it may still not
00:46:48.621 --> 00:46:52.839 clear its memory, in which case there would actually be a real
00:46:52.839 --> 00:46:56.588 memory leak or an Unkilled connection leak, and so just
00:46:56.588 --> 00:47:00.606 keeping in mind that this is really important to not forget
00:47:00.606 --> 00:47:03.150 when you're using a database context.
00:47:06.030 --> 00:47:11.377 And you can also, as a fun fact, you can. Uh, this they call this
00:47:11.377 --> 00:47:16.401 an inline using in the old days this didn't exist, you had to
00:47:16.401 --> 00:47:17.940 scope it like this.
00:47:20.240 --> 00:47:22.390 Uh, and then?
00:47:23.030 --> 00:47:26.710 Put it inside of a body and then once this body ended, any used,
00:47:26.710 --> 00:47:30.391 uh variables in this inside the the using parentheses would fall
00:47:30.391 --> 00:47:33.958 out of scope, right? Well then they were like, I guess most of
00:47:33.958 --> 00:47:37.129 the time people are doing it like this where the entire
00:47:37.129 --> 00:47:40.866 method ends up being inside that scope. So they were like well, I
00:47:40.866 --> 00:47:44.490 guess we could just, you know, make people not have to have the
00:47:44.490 --> 00:47:44.830 extra.
00:47:45.990 --> 00:47:49.047 At theses on there and just do that and then it's just whenever
00:47:49.047 --> 00:47:52.152 this variable falls out of scope in the scope that it's in, that
00:47:52.152 --> 00:47:54.350 counts. So a little bit of fun history there.
00:47:54.830 --> 00:47:58.120 Uh. So anyway, back to the original question.
00:47:59.050 --> 00:48:02.521 And I know I'm kind of I'm. I'm squarely when I talk, so
00:48:02.521 --> 00:48:03.130 apologies.
00:48:03.670 --> 00:48:07.212 Umm, but actually getting into using the database, so this
00:48:07.212 --> 00:48:10.814 method this call right here actually gets you. Like I said,
00:48:10.814 --> 00:48:14.356 a window into the database and so let's say that you don't
00:48:14.356 --> 00:48:17.478 know, let's say that you're gonna read some product
00:48:17.478 --> 00:48:21.320 information by its ID. So we're going to pass a product ID into
00:48:21.320 --> 00:48:21.620 this.
00:48:23.670 --> 00:48:26.345 If you wanted to make a call that reads the name of the
00:48:26.345 --> 00:48:27.300 product for that ID.
00:48:30.230 --> 00:48:33.247 I'm not gonna make it async yet, just because that makes it more
00:48:33.247 --> 00:48:36.125 confusing, so the context is your window context dot and look
00:48:36.125 --> 00:48:38.817 at that. There's all the tables in the database, so we're
00:48:38.817 --> 00:48:41.602 looking at the product table. So we're gonna do context dot
00:48:41.602 --> 00:48:42.020 products.
00:48:43.140 --> 00:48:46.542 I'm not gonna wrap these as as we normally would because that's
00:48:46.542 --> 00:48:47.340 also confusing.
00:48:48.860 --> 00:48:53.391 But this is basically like every product in the database right
00:48:53.391 --> 00:48:57.850 here. I could you know I wanted to you could do A2 list here.
00:48:59.230 --> 00:49:02.685 And this would be the world's slowest call, but it would list
00:49:02.685 --> 00:49:06.084 you out every single product in the database and the type of
00:49:06.084 --> 00:49:06.920 this is a list.
00:49:07.870 --> 00:49:10.040 Of clarity commerce data model product.
00:49:11.930 --> 00:49:15.795 This OK, this will get your your your pull request rejected. So
00:49:15.795 --> 00:49:16.640 don't do this.
00:49:18.120 --> 00:49:22.454 But that's that's the process. So what I mentioned earlier is
00:49:22.454 --> 00:49:26.998 that entity framework allows us to write plain looking C# and it
00:49:26.998 --> 00:49:31.473 handles converting it into SQL for us and querying the database
00:49:31.473 --> 00:49:33.500 and all that. So to that end.
00:49:34.270 --> 00:49:34.820 Umm.
00:49:35.900 --> 00:49:37.940 What what we would do here is.
00:49:39.500 --> 00:49:42.875 You know, just as a as a sample we we know that the sequel for
00:49:42.875 --> 00:49:44.000 this would look like.
00:49:45.820 --> 00:49:46.810 Something like this?
00:49:53.570 --> 00:49:58.374 Right, so this is basically the SQL that we want to, you know,
00:49:58.374 --> 00:50:01.500 write some C that to to handle right so.
00:50:05.990 --> 00:50:07.740 What we need to do first is.
00:50:07.820 --> 00:50:11.240 Yes, we can use this method called where.
00:50:12.530 --> 00:50:18.348 And it accepts a A basically a function that returns true or
00:50:18.348 --> 00:50:18.920 false.
00:50:20.140 --> 00:50:20.650 Umm.
00:50:22.560 --> 00:50:28.393 So now this is effectively like if I were to do just like this,
00:50:28.393 --> 00:50:33.589 this SQL here is basically select star from products dot
00:50:33.589 --> 00:50:36.870 product where ID equals product ID.
00:50:37.630 --> 00:50:41.209 So that's this is what we have right here, almost what we want.
00:50:41.209 --> 00:50:44.788 But what we want, we don't want to select star, we just want to
00:50:44.788 --> 00:50:45.850 select name, right.
00:50:47.290 --> 00:50:50.240 So then we also have another.
00:50:51.870 --> 00:50:55.364 We'll call this like whole product, right? Move this down
00:50:55.364 --> 00:50:56.750 here. Move this up one.
00:50:58.430 --> 00:50:59.170 Steal that.
00:51:00.200 --> 00:51:04.830 Product name what we want is to only select or take.
00:51:06.070 --> 00:51:11.746 The name uh and so thankfully in C# it has that exact name
00:51:11.746 --> 00:51:12.420 select.
00:51:12.740 --> 00:51:13.330 Umm.
00:51:15.160 --> 00:51:20.406 And we use this same notation of X being the product error X dot
00:51:20.406 --> 00:51:20.810 name.
00:51:22.030 --> 00:51:22.670 And so.
00:51:23.520 --> 00:51:27.462 Now the return for this is an I queryable of a string, which
00:51:27.462 --> 00:51:31.275 would be its name. So now this is actually the SQL that we
00:51:31.275 --> 00:51:32.180 want, however.
00:51:33.140 --> 00:51:36.410 Something that's very important, very in my opinion. Very cool. I
00:51:36.410 --> 00:51:39.432 think it's really cool once you kind of understand like this
00:51:39.432 --> 00:51:41.760 whole. Like once it clicks for you. It's neat.
00:51:43.360 --> 00:51:44.530 Well, you'll notice is that.
00:51:44.970 --> 00:51:46.850 Umm these are not.
00:51:47.550 --> 00:51:51.333 This is not a product. This is not a string. This is an I
00:51:51.333 --> 00:51:55.247 queryable of a string. This is an I queryable of a problem.
00:51:55.247 --> 00:51:59.226 What that means basically is that this has not actually been
00:51:59.226 --> 00:52:03.205 executed against the database yet. All we've done is build a
00:52:03.205 --> 00:52:07.445 basically build a query. So this right here, once it's executed,
00:52:07.445 --> 00:52:11.489 it will run this SQL against the database, but it hasn't been
00:52:11.489 --> 00:52:15.403 executed yet. Same thing over here. It will execute the SQL
00:52:15.403 --> 00:52:17.490 against the database once we do.
00:52:18.360 --> 00:52:22.678 The execution process in our case in C# is called
00:52:22.678 --> 00:52:24.060 enumeration. UM.
00:52:24.780 --> 00:52:28.725 And you'll you'll know in numeration by. It almost always
00:52:28.725 --> 00:52:29.950 starts with, like.
00:52:30.980 --> 00:52:35.160 And either it's gonna say to list to dictionary first first
00:52:35.160 --> 00:52:39.550 or default, single, single or default. All that kind of stuff.
00:52:40.250 --> 00:52:40.930 UM.
00:52:42.110 --> 00:52:42.840 And so.
00:52:45.180 --> 00:52:47.820 That process effectively is.
00:52:48.520 --> 00:52:49.120 Umm.
00:52:50.370 --> 00:52:55.333 Is saying OK, run the sequel and give me back what matches,
00:52:55.333 --> 00:52:56.160 right? So?
00:52:57.260 --> 00:53:00.860 I'm wrapping this so that it looks a little bit easier to
00:53:00.860 --> 00:53:04.459 read now a little bit clearer. UM, so if we if we want to
00:53:04.459 --> 00:53:08.245 enumerate this or actually go and execute the SQL, there's a
00:53:08.245 --> 00:53:12.217 handful of ways that we can do it. So let's say that we weren't
00:53:12.217 --> 00:53:16.127 filtering by ID and we had some other filter that could return
00:53:16.127 --> 00:53:18.610 10 products or something, I don't know.
00:53:19.910 --> 00:53:23.077 Then instead of doing, we would want to get back all of the
00:53:23.077 --> 00:53:26.296 matching results, right? We don't just want a single one, so
00:53:26.296 --> 00:53:28.830 in that case we would do something like 2 list.
00:53:29.690 --> 00:53:33.497 And now right here, this is now an actual just straight list of
00:53:33.497 --> 00:53:36.828 strings. It's not. It's no longer an I queryable. We've
00:53:36.828 --> 00:53:38.910 handled this this two list method.
00:53:39.750 --> 00:53:42.614 Enumerates the query. It executes, so whenever that
00:53:42.614 --> 00:53:45.808 enumeration happens, the database context will go and say
00:53:45.808 --> 00:53:49.113 OK you want products where ID equals this and you want just
00:53:49.113 --> 00:53:52.362 the name. OK builds the SQL, runs it against the database,
00:53:52.362 --> 00:53:55.777 brings the results back to you, and gives it back in whatever
00:53:55.777 --> 00:53:58.310 format you asked for it. In this case a list.
00:53:59.020 --> 00:53:59.480 Umm.
00:54:00.440 --> 00:54:04.646 Uh, there's uh, let's say that you want something a little bit
00:54:04.646 --> 00:54:04.980 more.
00:54:05.060 --> 00:54:05.640 Uh.
00:54:06.860 --> 00:54:10.165 Specific so in this case we know that we are we are only
00:54:10.165 --> 00:54:13.933 expecting to get one thing back because we're filtering by an ID
00:54:13.933 --> 00:54:16.310 and you can't have duplicate IDs in SQL.
00:54:17.870 --> 00:54:22.062 So in that scenario, there's a grand total of four methods, but
00:54:22.062 --> 00:54:26.385 there's basically 2 methods with two variants each that you could
00:54:26.385 --> 00:54:28.350 use for this first and single.
00:54:30.140 --> 00:54:33.518 These are the methods that give you that fantastic error message
00:54:33.518 --> 00:54:34.610 we all know and love.
00:54:36.030 --> 00:54:40.365 And I hope you can sense the sarcasm. The error message that
00:54:40.365 --> 00:54:44.416 says sequence contains no elements or sequence contained
00:54:44.416 --> 00:54:47.330 more than one element or whatever it is.
00:54:48.030 --> 00:54:50.490 These these are the culprits of those messages.
00:54:51.220 --> 00:54:55.292 Uh, everybody's probably seen them. If you haven't, it's only
00:54:55.292 --> 00:54:58.510 a matter of time. I promise you will eventually.
00:54:59.650 --> 00:55:00.070 But.
00:55:01.040 --> 00:55:01.830 Uh.
00:55:03.740 --> 00:55:07.721 Basically what these do and each of these first and singles have
00:55:07.721 --> 00:55:11.518 an or default variation to them, and and I'll talk about what
00:55:11.518 --> 00:55:13.110 that means in a moment so.
00:55:14.150 --> 00:55:17.890 Right here. So we're two lists. Gave us back a.
00:55:20.250 --> 00:55:23.693 A list of all the matches first is only going to give us back
00:55:23.693 --> 00:55:27.024 the first match for this query. Obviously in our case we're
00:55:27.024 --> 00:55:30.522 filtering by it either is only one match, so this is basically
00:55:30.522 --> 00:55:32.410 just give me back the only match.
00:55:33.120 --> 00:55:36.660 And you can see that instead of giving me back any sort of.
00:55:38.500 --> 00:55:41.563 Like wrapped object anything, it just straight gives me the
00:55:41.563 --> 00:55:43.350 string. That's all it's giving me.
00:55:45.430 --> 00:55:45.940 Yeah, what's up?
00:55:46.950 --> 00:55:51.399 So are these is that C# that you're writing with the dot
00:55:51.399 --> 00:55:56.160 where dot select dot first? Or is that the entity framework?
00:55:57.110 --> 00:56:00.390 That's a fantastic question and I'm very glad you asked that.
00:56:01.090 --> 00:56:05.762 These are standard link methods. Link is a utility that we have
00:56:05.762 --> 00:56:10.435 in C# for querying and working with collections of data. So you
00:56:10.435 --> 00:56:12.260 can actually see up here.
00:56:13.390 --> 00:56:17.560 This is the Excel import provider where we're.
00:56:18.190 --> 00:56:20.540 Fixing the importer for Umm. For PCs.
00:56:21.540 --> 00:56:25.271 This is not a database, this is an Excel sheet, but I can still
00:56:25.271 --> 00:56:28.826 query against it with the exact same method. Select where to
00:56:28.826 --> 00:56:32.207 list whatever it is and any is also linked. All these are
00:56:32.207 --> 00:56:35.355 doing. These are just convenience methods that handle
00:56:35.355 --> 00:56:37.220 certain things entity framework.
00:56:37.970 --> 00:56:42.170 Knows how to basically analyze a dot where and A dot select and
00:56:42.170 --> 00:56:46.437 convert it into SQL for you. And you I don't understand how that
00:56:46.437 --> 00:56:50.112 works. You don't have to understand how that works. The
00:56:50.112 --> 00:56:54.050 cool thing is that as soon as you understand the concept of
00:56:54.050 --> 00:56:57.922 where and select and anything like that anywhere, any Lync
00:56:57.922 --> 00:57:01.926 concept, those work with entity framework and get transpiled
00:57:01.926 --> 00:57:04.420 into native SQL and it's really cool.
00:57:05.060 --> 00:57:09.459 So to find these methods would is are there like would we go to
00:57:05.150 --> 00:57:05.620 Uh.
00:57:09.459 --> 00:57:13.376 like the link docs or what documentation will be look at
00:57:09.480 --> 00:57:10.500 Ohh yeah you can.
00:57:12.210 --> 00:57:15.987 Yeah, yeah, you can just look up. Uh, yeah, C# link
00:57:13.376 --> 00:57:13.720 link.
00:57:15.987 --> 00:57:20.563 documentation. Yeah. And you can go and understand. Yeah. It's
00:57:20.563 --> 00:57:25.284 language integrated query. We do not use this syntax for Lync we
00:57:25.284 --> 00:57:25.720 don't.
00:57:25.880 --> 00:57:29.250 Uh, I I personally hate this. I think it's terrible. It's like
00:57:29.250 --> 00:57:32.513 worst sequel. I don't like. I don't like writing SQL anyway,
00:57:32.513 --> 00:57:35.830 but this is just like somebody was like, let's make it worse.
00:57:37.230 --> 00:57:38.920 So don't use this.
00:57:40.390 --> 00:57:43.050 It's a proud Microsoft developer out there.
00:57:43.630 --> 00:57:47.966 Well, I I'm sure he's proud of it and I'm I'm sure I'm sure
00:57:45.000 --> 00:57:46.910 Every time we bass on something.
00:57:47.966 --> 00:57:52.373 that the technology behind how this works is impressive. The
00:57:52.373 --> 00:57:54.180 syntax just sucks is all.
00:57:54.960 --> 00:57:59.472 Umm, so he can be proud of it. That's fine. I just don't like
00:57:59.472 --> 00:57:59.690 it.
00:58:02.390 --> 00:58:06.852 So, but ultimately, these work exactly the same way. This is
00:58:06.852 --> 00:58:11.460 the same as like where X arrow X dot score is greater than 80.
00:58:12.770 --> 00:58:16.733 This is entirely perfunctory and pointless, which is another
00:58:16.733 --> 00:58:20.891 reason I don't like this. This like this function style syntax,
00:58:20.891 --> 00:58:22.840 is that that's even necessary.
00:58:23.480 --> 00:58:26.150 Umm. But anyway.
00:58:26.680 --> 00:58:27.480 Uh.
00:58:28.640 --> 00:58:31.013 They've got a bunch of documentation in here that kind
00:58:31.013 --> 00:58:32.480 of explains how this stuff works.
00:58:33.310 --> 00:58:36.008 Unfortunately, it seems like most of it is in this gross
00:58:36.008 --> 00:58:38.942 format. It also sucks because whenever it's time to enumerate
00:58:38.942 --> 00:58:41.877 a query, you have to like wrap the whole thing in parentheses
00:58:41.877 --> 00:58:44.953 and you still have to call like .2 lists like a method, and it's
00:58:44.953 --> 00:58:47.983 like, well, why don't you just do that the whole time? You know
00:58:47.983 --> 00:58:48.740 it's way easier.
00:58:51.130 --> 00:58:52.640 And it's much easier to read.
00:58:52.090 --> 00:58:52.500 Mm-hmm.
00:58:53.780 --> 00:58:54.470 So anyway.
00:58:56.160 --> 00:58:59.756 Yes, you can look up any sort of link documentation, a tool I
00:58:59.756 --> 00:59:02.830 strongly recommend if you plan on getting more into.
00:59:03.870 --> 00:59:07.491 C# development in general, whether it's in or in or outside
00:59:07.491 --> 00:59:10.750 of Stafford, clarity uh link pad is a fantastic tool.
00:59:11.390 --> 00:59:15.724 Umm you can change language up here to C# program and you can
00:59:15.724 --> 00:59:20.199 write an entire C# program here and then just click play and it
00:59:20.199 --> 00:59:24.603 will run the code for you and output what you want. So you can
00:59:24.603 --> 00:59:27.050 do like var some stuff equals new.
00:59:28.200 --> 00:59:34.920 Uh, I've 101518192229 sure, why not?
00:59:36.530 --> 00:59:43.337 And then you can do really fun stuff in here like events equals
00:59:43.337 --> 00:59:45.570 some stuff dot where.
00:59:46.610 --> 00:59:50.100 Uh, X percent 2 = 0.
00:59:53.660 --> 00:59:57.330 And then for each like even and even.
00:59:58.730 --> 01:00:02.774 Console write line even and run this and it should theoretically
01:00:02.774 --> 01:00:06.508 only give you back the even numbers and this collection. So
01:00:06.508 --> 01:00:10.179 yeah, again, this is obviously not a database, it's just a
01:00:10.179 --> 01:00:14.099 collection of data and this dot where is executed against each
01:00:14.099 --> 01:00:15.530 item in the collection.
01:00:16.130 --> 01:00:20.378 Umm. And it's literally this function is executed where X is
01:00:20.378 --> 01:00:24.486 one of these values. So five it's gonna pass that in five.
01:00:24.486 --> 01:00:29.013 Modulus 2 is not zero, it's one so that returns false. So five's
01:00:29.013 --> 01:00:33.191 not in the final collection passes in 1010, Modulus 2 is 0,
01:00:33.191 --> 01:00:37.160 so 10 will be in your final collection of events, right?
01:00:37.710 --> 01:00:41.200 Umm, there's some very interesting stuff about.
01:00:42.840 --> 01:00:46.868 In this exact code example about when the enumeration actually
01:00:46.868 --> 01:00:47.380 happens.
01:00:49.510 --> 01:00:52.268 But I won't. I won't go through all of that because it's
01:00:52.268 --> 01:00:55.413 confusing and it doesn't really matter to you guys. Uh, it's not
01:00:55.413 --> 01:00:57.590 something that you're gonna really run into.
01:00:59.840 --> 01:01:03.388 And uh, to add on to what you just sent in the chat there
01:01:03.388 --> 01:01:07.364 about how dot where is the same as dot filter, it is exactly the
01:01:07.364 --> 01:01:10.851 same as dot filter and dot select is exactly the same as
01:01:10.851 --> 01:01:11.340 dot map.
01:01:14.320 --> 01:01:15.920 Oh, wow, that's nice now.
01:01:14.420 --> 01:01:14.950 So.
01:01:16.310 --> 01:01:17.900 Yep, and.
01:01:17.290 --> 01:01:21.358 Something else that I just caught is link is like seriously
01:01:21.358 --> 01:01:25.630 built into C#. You don't have to import anything extra, right?
01:01:24.860 --> 01:01:28.493 Yep, Yep. The only thing that you have to do is there's this
01:01:28.493 --> 01:01:32.186 using system dot link, but this is always available to you. A
01:01:32.186 --> 01:01:35.759 brand new, completely empty C# project will have system dot
01:01:35.759 --> 01:01:39.333 link. You can add this using without him to go get a nugget
01:01:39.333 --> 01:01:42.370 package or anything like that. It is built into C.
01:01:43.760 --> 01:01:46.080 And then link doesn't.
01:01:43.810 --> 01:01:45.840 So this is a. This is a core feature.
01:01:47.050 --> 01:01:50.003 Yeah. Then the next piece that I noticed is link doesn't have to
01:01:50.003 --> 01:01:52.865 be applied to just like database calls, it could be applied to
01:01:51.990 --> 01:01:52.460 Correct.
01:01:52.865 --> 01:01:53.410 anything C#.
01:01:53.670 --> 01:01:58.039 Yep, any collection of information, the technical way
01:01:58.039 --> 01:02:02.650 to explain it is that Lynch operates on anything that is
01:02:02.650 --> 01:02:03.540 implicitly.
01:02:04.280 --> 01:02:06.580 Castable to I enumerable.
01:02:07.940 --> 01:02:12.165 But again, you don't really need to know that. All you really
01:02:12.165 --> 01:02:16.458 need to know is arrays, lists, dictionaries, database queries,
01:02:16.458 --> 01:02:20.614 all that kind of stuff. Those are in some way, shape or form
01:02:20.614 --> 01:02:24.430 innumerable, and therefore Lync can query against them.
01:02:24.970 --> 01:02:26.680 Umm. And so.
01:02:27.930 --> 01:02:33.000 Yeah, there is some important things to know about.
01:02:33.680 --> 01:02:37.041 Umm about writing database queries that I can talk about
01:02:37.041 --> 01:02:37.690 real quick.
01:02:40.050 --> 01:02:42.800 Uh, so kind of getting back to where we were over here. I was
01:02:42.800 --> 01:02:44.220 talking about this first method.
01:02:45.860 --> 01:02:47.220 The problem here.
01:02:48.020 --> 01:02:50.660 Is that this first method?
01:02:51.620 --> 01:02:56.545 Is basically saying there will always be at least one result.
01:02:56.545 --> 01:02:58.690 Give me back the first one.
01:03:01.400 --> 01:03:05.082 The problem then becomes what if this product ID? Excuse me, what
01:03:05.082 --> 01:03:08.430 if this product ID doesn't match a product in the database?
01:03:09.140 --> 01:03:11.410 Well, that's where that error message I was talking about
01:03:11.410 --> 01:03:11.840 comes from.
01:03:12.560 --> 01:03:16.407 If you if the SQL that this generates to this right here has
01:03:16.407 --> 01:03:20.380 no object, there's no database record that matches your query.
01:03:21.950 --> 01:03:25.820 And you called dot first, you're going to get back. The wonderful
01:03:25.820 --> 01:03:29.398 sequence contains no elements because you're saying first is
01:03:29.398 --> 01:03:33.034 effectively saying. I guarantee you there will be a result. I
01:03:33.034 --> 01:03:36.846 just need the first one and it's going to throw an error because
01:03:36.846 --> 01:03:40.130 it's saying there's not anything. There are no results,
01:03:40.130 --> 01:03:42.710 and you're telling me there will be and so.
01:03:44.320 --> 01:03:47.914 On the on the, on the face of it, it sounds kind of annoying.
01:03:47.914 --> 01:03:51.334 It sounds like that's something you wouldn't want, but the
01:03:51.334 --> 01:03:54.696 reality is that this allows us to enforce certain certain
01:03:54.696 --> 01:03:58.407 constraints. For example, there should only ever be one product
01:03:58.407 --> 01:03:59.450 that matches this.
01:04:01.310 --> 01:04:05.366 And so for that type of behavior we have the other side of this
01:04:05.366 --> 01:04:05.810 single.
01:04:06.960 --> 01:04:07.640 Single.
01:04:08.400 --> 01:04:12.414 Is similar to 1st, which is just give me back the results. The
01:04:12.414 --> 01:04:15.918 one singular result. The difference is that first says
01:04:15.918 --> 01:04:19.677 there will always be at least one result or up to infinite
01:04:19.677 --> 01:04:23.436 results. Who cares how many single is there will only ever
01:04:23.436 --> 01:04:26.877 be one and only one result exactly, not 0, not 2, not
01:04:26.877 --> 01:04:27.960 anything but one.
01:04:28.670 --> 01:04:31.837 That makes sense when you're filtering by an ID, because
01:04:31.837 --> 01:04:35.281 there can only ever be one thing in a database table that has
01:04:35.281 --> 01:04:38.948 that specific ID. You can't have two things with ID of 10, right?
01:04:38.948 --> 01:04:42.059 So it makes sense to say that there will only ever be a
01:04:42.059 --> 01:04:43.170 singular match here.
01:04:44.190 --> 01:04:47.367 However, once again, this suffers from the same problem.
01:04:47.367 --> 01:04:50.768 If you pass in 20 and there's no product ID 20 in the in the
01:04:50.768 --> 01:04:54.113 database, you'll get the same exact error message. Sequence
01:04:54.113 --> 01:04:57.290 contains no elements, so if you want to write code that.
01:04:58.050 --> 01:05:01.639 Shouldn't necessarily fail if a product ID is invalid, which is
01:05:01.639 --> 01:05:05.171 relatively uncommon, or you want to handle the error yourself.
01:05:05.171 --> 01:05:08.704 Whatever it is, then rather than using one of these, you would
01:05:08.704 --> 01:05:12.292 add or default onto the end and what that will tell you here is
01:05:12.292 --> 01:05:15.600 it will return the single element of the input sequence or
01:05:15.600 --> 01:05:18.965 default if the sequence contains no elements. So instead of
01:05:18.965 --> 01:05:22.441 throwing an error, this will just return the default value of
01:05:22.441 --> 01:05:25.805 its type. So in this case the strings default value is null
01:05:25.805 --> 01:05:29.001 because it's a reference type like we were talking about
01:05:29.001 --> 01:05:29.450 earlier.
01:05:30.030 --> 01:05:31.190 And so now.
01:05:32.320 --> 01:05:36.265 If this query matches two or more things, it will throw an
01:05:36.265 --> 01:05:40.209 error because single enforces that it will. That will only
01:05:40.209 --> 01:05:44.355 have 1 result, but if it's empty it won't throw an exception,
01:05:44.355 --> 01:05:48.500 it'll just return null. So this is. This basically says there
01:05:48.500 --> 01:05:52.311 can be zero or one results. Those are the two acceptable
01:05:52.311 --> 01:05:56.523 scenarios. 0 or one results 2 or more is still a failure state
01:05:56.523 --> 01:06:00.468 because that implies that somehow the database has stopped
01:06:00.468 --> 01:06:01.270 functioning.
01:06:01.430 --> 01:06:03.030 And that's a really big problem.
01:06:03.630 --> 01:06:08.175 Uh, so theoretically this would never happen. Uh, like this
01:06:08.175 --> 01:06:11.660 would this would never throw on an ID filter.
01:06:12.980 --> 01:06:16.724 Because if it did, you've got way bigger problems than
01:06:16.724 --> 01:06:20.809 whatever you're trying to fix. If your database is is doing
01:06:20.809 --> 01:06:25.166 that to you, so, but the first method has the same thing, first
01:06:25.166 --> 01:06:29.182 or default, so this one is saying absolutely any number of
01:06:29.182 --> 01:06:30.680 results is acceptable.
01:06:31.400 --> 01:06:34.398 If there are any in the result set, just give me back the first
01:06:34.398 --> 01:06:37.396 one. I don't care about the rest if there are none, don't throw
01:06:37.396 --> 01:06:40.301 an error, just return default which most of the time is gonna
01:06:40.301 --> 01:06:40.910 be like null.
01:06:41.710 --> 01:06:42.220 Umm.
01:06:43.330 --> 01:06:47.083 So, uh, generally speaking, you'll see. You'll see first or
01:06:47.083 --> 01:06:50.961 default or single or default used a lot more than just a just
01:06:50.961 --> 01:06:52.650 a straight first or single.
01:06:54.390 --> 01:06:57.986 But there are there are places where it makes sense to use all
01:06:57.986 --> 01:07:01.240 of them, and then like I mentioned earlier, you can also
01:07:01.240 --> 01:07:04.837 two list if you know that your query is gonna return more than
01:07:04.837 --> 01:07:07.120 one and you wanna get back all of them.
01:07:07.790 --> 01:07:11.026 Uh, you can. There's more complex stuff. Uh, like if we
01:07:11.026 --> 01:07:14.840 comment out this select, you can do cool stuff like 2 dictionary.
01:07:15.430 --> 01:07:21.151 Uh. Or the key of the dictionary is the custom key and the value
01:07:21.151 --> 01:07:23.000 is. I don't know the.
01:07:25.380 --> 01:07:29.022 Price base I guess and this would give you a map where the
01:07:29.022 --> 01:07:32.848 key is that like the skin of the product and the value is the
01:07:32.848 --> 01:07:36.305 price of that product and you see the type of that is a
01:07:36.305 --> 01:07:40.070 Dictionary of a string and a decimal. So that's pretty cool.
01:07:40.250 --> 01:07:45.031 Umm. And this is actually again, this is built right into SQL.
01:07:45.031 --> 01:07:49.356 This will effectively this translates into select custom
01:07:49.356 --> 01:07:49.660 key.
01:07:51.440 --> 01:07:55.444 Price base from products dot product where ID equals whatever
01:07:55.444 --> 01:07:59.448 and then you could even if you wanted to get rid of this then
01:07:59.448 --> 01:08:03.387 this would basically be like getting the mapping of the skew
01:08:03.387 --> 01:08:06.810 to price of every product in the database right? So.
01:08:08.330 --> 01:08:09.680 Bring your stuff. You can do there.
01:08:10.080 --> 01:08:14.999 Umm, but hopefully that answers your question about how to
01:08:14.999 --> 01:08:20.336 actually like use and query the database and some of the entity
01:08:20.336 --> 01:08:21.670 framework stuff.
01:08:26.860 --> 01:08:29.170 Yeah, for sure, man. I think so, Alex.
01:08:30.750 --> 01:08:32.920 Yeah, this is hugely helpful.
01:08:33.570 --> 01:08:34.000 Awesome.
01:08:35.490 --> 01:08:38.993 There's again with when it comes to querying the database and
01:08:38.993 --> 01:08:42.384 using entity framework, there's a lot of little things that
01:08:42.384 --> 01:08:45.887 you'll probably like if you're writing a query, you might run
01:08:45.887 --> 01:08:46.170 into.
01:08:47.730 --> 01:08:50.654 And generally speaking, I my intent with this wasn't
01:08:50.654 --> 01:08:54.019 necessarily to go like all the way into the weeds with stuff
01:08:54.019 --> 01:08:57.604 like that. It's just giving you guys the tools to read this code
01:08:57.604 --> 01:09:00.859 and like, if you're reading somebody's database query, you
01:09:00.859 --> 01:09:03.948 understand what it's doing, right? So that's the whole,
01:09:03.948 --> 01:09:07.258 that's the whole idea here is that now you can look at this
01:09:07.258 --> 01:09:10.623 right here and understand it like, OK, we'll context. That's
01:09:10.623 --> 01:09:14.154 the database. We're going into the products table, filtering by
01:09:14.154 --> 01:09:16.140 ID, selecting the name and getting.
01:09:16.360 --> 01:09:19.630 You know, whatever the 1st result may be, if there is one.
01:09:20.810 --> 01:09:24.146 And this the whole idea here was now you guys can read this and
01:09:24.146 --> 01:09:27.482 it's not, you know, it doesn't. It doesn't have to be confusing
01:09:27.482 --> 01:09:30.871 or or you don't have to defer to somebody else to have you to be
01:09:30.871 --> 01:09:34.051 able to tell you what it means. You'll be able to just debug
01:09:34.051 --> 01:09:34.520 yourself.
01:09:36.040 --> 01:09:36.810 And then.
01:09:38.070 --> 01:09:39.040 Yeah. So.
01:09:40.990 --> 01:09:44.820 Uh, let's see. What else was there to cover here?
01:09:45.680 --> 01:09:46.330 Uh.
01:09:47.860 --> 01:09:52.745 I guess I mean that pretty much covers it for the data, the data
01:09:52.745 --> 01:09:55.300 model layer. If if you guys were.
01:09:56.060 --> 01:09:59.750 Getting more into uh, like actual day-to-day back end work,
01:09:59.750 --> 01:10:03.379 I'd probably spend a lot more time in this layer. And it's
01:10:03.379 --> 01:10:07.069 funny because I just talked to in this one for like an hour
01:10:07.069 --> 01:10:07.930 straight, but.
01:10:09.270 --> 01:10:10.500 This is this is.
01:10:11.430 --> 01:10:15.693 For back end developers, this is where most of the hangup tends
01:10:15.693 --> 01:10:19.689 to be is is schema and database interop and learning how to
01:10:19.689 --> 01:10:22.820 write optimal SQL queries and stuff like that.
01:10:25.020 --> 01:10:30.204 Or I guess optimal optimal link queries that get converted into
01:10:30.204 --> 01:10:31.500 SQL, but anyway.
01:10:32.570 --> 01:10:36.100 Uh, OK, I'll move on. Uh, interfaces.
01:10:37.350 --> 01:10:40.700 Doesn't matter, it does, but it doesn't.
01:10:42.090 --> 01:10:46.097 So we're just gonna, we're just gonna breeze right on through
01:10:46.097 --> 01:10:49.717 there. The only note I'll say here is you guys probably
01:10:49.717 --> 01:10:53.401 remember when I was talking about interfaces and classes
01:10:53.401 --> 01:10:57.214 earlier and the relationship between them and all that fun
01:10:57.214 --> 01:11:01.480 stuff. Well, this is where a lot of steps interfaces are, in fact
01:11:01.480 --> 01:11:02.320 specifically.
01:11:03.450 --> 01:11:06.963 Uh, I talked about I shipping provider earlier. Well, here's
01:11:06.963 --> 01:11:10.189 eye shipping provider. The actual eye shipping provider
01:11:10.189 --> 01:11:13.818 that stuff uses and it has get very quotes and ignore this one
01:11:13.818 --> 01:11:15.200 because nothing uses it.
01:11:16.470 --> 01:11:19.808 But it has a get rate quotes method on it just like the the
01:11:19.808 --> 01:11:23.035 sample that I put together earlier to kind of convey this
01:11:23.035 --> 01:11:26.206 point and similarly the pricing provider as an I pricing
01:11:26.206 --> 01:11:29.767 provider base an interface that says all pricing providers will
01:11:29.767 --> 01:11:32.660 allow you to get a price key and calculate a price.
01:11:34.000 --> 01:11:34.450 So.
01:11:34.920 --> 01:11:37.981 Uh, this is where those interfaces are stored 99.9% of
01:11:37.981 --> 01:11:41.487 the time. You're not gonna have to change them. It's very rare
01:11:41.487 --> 01:11:44.270 that the interfaces for providers have to change.
01:11:45.710 --> 01:11:49.427 The only thing you guys will probably ever need to touch in
01:11:49.427 --> 01:11:52.896 interfaces as front Enders is interfaces dot models and
01:11:52.896 --> 01:11:56.985 specifically you'll want to look at something like something like
01:11:56.985 --> 01:12:00.702 what David just did. It might have even been on PCs I can't
01:12:00.702 --> 01:12:01.260 remember.
01:12:03.240 --> 01:12:06.826 He needed to map out some extra information on the user model,
01:12:06.826 --> 01:12:10.299 so when the user model comes out to you on the front end, he
01:12:10.299 --> 01:12:12.690 needed like a couple of extra cool stuff.
01:12:13.380 --> 01:12:17.249 We have this convenience properties region here where you
01:12:17.249 --> 01:12:21.384 can come in here and add new stuff when you add this you have
01:12:21.384 --> 01:12:25.654 to add it to the interface and the and the class and so this is
01:12:25.654 --> 01:12:29.789 the first place to start. So let's say that you wanted to map
01:12:29.789 --> 01:12:30.990 out, I don't know.
01:12:31.780 --> 01:12:32.570 Uh.
01:12:34.150 --> 01:12:37.650 A number of orders for some reason.
01:12:38.820 --> 01:12:42.533 Uh, like some piece of front end code? Wanted every user that
01:12:42.533 --> 01:12:46.126 comes back from the back end to have a a property on it for
01:12:46.126 --> 01:12:49.540 number of orders. Well, obviously we're not gonna store.
01:12:50.200 --> 01:12:54.094 That value directly on the the data like the the database table
01:12:54.094 --> 01:12:57.927 for the user. We're not gonna go make a schema change and then
01:12:57.927 --> 01:13:01.821 everywhere that an order might get generated, we're going to go
01:13:01.821 --> 01:13:05.532 update that value. That's way too tedious. We can just query
01:13:05.532 --> 01:13:09.366 for all the orders for this user and so that's how we would do
01:13:09.366 --> 01:13:13.077 that just to justify my weird sample here. So we'll add. I'm
01:13:13.077 --> 01:13:16.302 not going to add this documentation graph. And again
01:13:16.302 --> 01:13:19.587 for this demonstration, it doesn't matter if you were
01:13:19.587 --> 01:13:21.230 making a real pull request.
01:13:21.540 --> 01:13:24.940 Boy, would it matter not to me, but it would matter.
01:13:26.640 --> 01:13:29.670 So number of orders? Yeah. What's up?
01:13:30.780 --> 01:13:34.678 Umm, I was kind of just. I just wanna get this out so I don't
01:13:34.678 --> 01:13:38.640 forget it. But if you could go through like a specific example
01:13:34.860 --> 01:13:35.300 Yeah, yeah.
01:13:38.640 --> 01:13:42.161 of showing us like where to find a data transfer object
01:13:42.161 --> 01:13:42.790 interface.
01:13:42.680 --> 01:13:45.710 Absolutely. Yep. Uh. So.
01:13:45.020 --> 01:13:48.626 Is those are things where I've had to like manually just add it
01:13:48.626 --> 01:13:52.119 to the interface on the front end. So I'm curious, where does
01:13:52.119 --> 01:13:55.613 it get added? If we're adding a property to a DTO in the back
01:13:55.613 --> 01:13:59.163 end. So where do we add it? And then how does that transfer to
01:13:58.040 --> 01:13:58.450 Yep.
01:13:59.163 --> 01:14:01.923 the front end? Is it from running at four in the
01:14:01.923 --> 01:14:04.290 interfaces folder? Or where is that done?
01:14:04.240 --> 01:14:07.199 That that is a really good question. So I'll I'll skip on
01:14:07.199 --> 01:14:10.210 the other half of what I was gonna show here and I'll show
01:14:10.210 --> 01:14:13.425 exactly that. I'll show getting this number of orders property
01:14:13.425 --> 01:14:16.639 to the front end. So assuming some back end or writes the code
01:14:16.639 --> 01:14:19.854 that populates this here's where you need to add it. So number
01:14:19.854 --> 01:14:22.966 one, let's say we're adding this on to user model. So you're
01:14:22.966 --> 01:14:26.181 wanting to add on to the user model and the front end a number
01:14:26.181 --> 01:14:29.396 of orders property. So we had to start at I user model the the
01:14:29.396 --> 01:14:32.610 interface is kind of the bottom level for this. So we're going
01:14:32.610 --> 01:14:34.090 to start there, we added our.
01:14:34.210 --> 01:14:37.778 The number of orders that is always gonna be under O2
01:14:37.778 --> 01:14:41.809 clarity, commerce, interfaces, models, and they're sorted by
01:14:41.809 --> 01:14:45.708 the same way they are in the database. So the content, the
01:14:45.708 --> 01:14:49.871 table for user is contacts dot user. So you go in the contacts
01:14:49.871 --> 01:14:53.440 folder and you find I user model dot extended dot CS.
01:14:54.990 --> 01:14:56.830 This file may not always exist.
01:14:58.090 --> 01:15:01.634 You'll always see something like I user model dot generated dot
01:15:01.634 --> 01:15:01.800 CS.
01:15:02.670 --> 01:15:06.213 These files are generated automatically by uh by the D
01:15:06.213 --> 01:15:06.600 fours.
01:15:06.840 --> 01:15:10.356 Umm. And so you don't ever want to add anything or change these
01:15:10.356 --> 01:15:13.487 files. These these will any change you make in here gets
01:15:13.487 --> 01:15:17.058 overwritten the next time the T4 runs. It's a waste of your time
01:15:17.058 --> 01:15:20.244 to even bother touching this file. You can read it if you
01:15:20.244 --> 01:15:23.540 need to if you feel like you'll get some value out of that.
01:15:25.510 --> 01:15:26.500 It's perfectly.
01:15:25.600 --> 01:15:29.495 You will get shut down by JG every time on a PR. I always
01:15:28.080 --> 01:15:31.539 Yeah. Well, and and and and myself as well, because again,
01:15:29.495 --> 01:15:30.570 look at the top.
01:15:31.539 --> 01:15:34.998 it's a waste of your time to modify these files the moment
01:15:34.998 --> 01:15:38.457 anybody runs at 4, your change will be gone, and they they
01:15:38.457 --> 01:15:42.267 won't care or know that you had anything in there. And so, yeah,
01:15:42.267 --> 01:15:46.019 you can tell if a file any file that's autogenerated by T force
01:15:46.019 --> 01:15:49.595 will have the very first line auto generated somewhere up in
01:15:49.595 --> 01:15:53.347 this header. Almost always the very first line. But at the very
01:15:53.347 --> 01:15:56.982 least, somewhere in this header it will say autogenerated. If
01:15:56.982 --> 01:15:57.920 that's in there.
01:15:58.660 --> 01:15:59.530 Don't touch the file.
01:16:00.130 --> 01:16:03.723 Umm it's you can read it. Like I said, it's not. It's not like a
01:16:03.723 --> 01:16:07.315 node to even open this file. You can open this thing up and look
01:16:07.315 --> 01:16:10.631 at everything in here. All you want that is perfectly fine.
01:16:10.631 --> 01:16:13.948 Just don't change anything cuz it's not gonna save it or it
01:16:13.948 --> 01:16:15.440 will save it until someone.
01:16:15.850 --> 01:16:16.360 Uh.
01:16:17.650 --> 01:16:18.370 134.
01:16:18.520 --> 01:16:19.400 Big waste of time.
01:16:18.690 --> 01:16:20.910 Umm yeah so.
01:16:22.690 --> 01:16:26.563 But if the file for like like let's say that I user model dot
01:16:26.563 --> 01:16:28.250 extended didn't exist here.
01:16:29.350 --> 01:16:33.044 You can go up to the folder, right click, add new item and
01:16:33.044 --> 01:16:36.989 then go create it and that's the name that you'd use. So let's
01:16:36.989 --> 01:16:40.996 say that we were doing, I don't know, for some reason I contact
01:16:40.996 --> 01:16:44.628 image model doesn't have an extended. I would go create a
01:16:44.628 --> 01:16:45.630 new item called.
01:16:46.800 --> 01:16:51.720 I contact image model dot extended dot CS.
01:16:52.520 --> 01:16:56.618 And my personal approach to this I I put the generated one and my
01:16:56.618 --> 01:17:00.530 extended one side by side and what I usually do is I copy this
01:17:00.530 --> 01:17:04.131 right here the namespace and I paste it over that so they
01:17:04.131 --> 01:17:05.000 exactly match.
01:17:05.690 --> 01:17:09.813 And then I steal this line and I paste it over this one. And now
01:17:09.813 --> 01:17:13.745 you're ready to do whatever you need to do right in here. You
01:17:13.745 --> 01:17:17.170 can go and add your custom properties, your extended.
01:17:17.240 --> 01:17:20.707 Like properties onto the user model or whatever it needs to
01:17:20.707 --> 01:17:20.880 be.
01:17:23.830 --> 01:17:24.550 So.
01:17:26.580 --> 01:17:31.178 And then the namespace is pretty much just the folder path right?
01:17:26.710 --> 01:17:27.920 If that files are missing.
01:17:31.178 --> 01:17:34.870 Clarity, ecommerce the we're in interfaces which is.
01:17:35.520 --> 01:17:38.630 Right. So it's it's not the full folder path because it doesn't
01:17:38.630 --> 01:17:41.691 have contacts on the end of it, but it's basically the name of
01:17:41.691 --> 01:17:44.655 the project that you're in, in this case, clarity, ecommerce
01:17:44.655 --> 01:17:47.570 interfaces, models, clarity, ecommerce, interfaces, models.
01:17:48.800 --> 01:17:51.740 And if you're not sure what your namespace should be, you can,
01:17:51.740 --> 01:17:54.727 like I said, that's why I like to put the generated one next to
01:17:54.727 --> 01:17:57.620 the extended one is because I can just copy from one into the
01:17:57.620 --> 01:17:59.720 other for the name of the file and all that.
01:18:00.830 --> 01:18:04.589 And that that, you know, just makes it easy. I don't have to.
01:18:03.630 --> 01:18:05.090 Yeah. Thank you. Thank you.
01:18:04.589 --> 01:18:07.620 I don't have to go look for it somewhere else so.
01:18:08.700 --> 01:18:12.699 But anyway, back to the the. Yes you you my mouse is being funny.
01:18:12.699 --> 01:18:16.516 There we go. Yeah. OK. So we've got our number of orders here.
01:18:16.516 --> 01:18:19.666 We've added it onto the interface. Once it's on the
01:18:19.666 --> 01:18:23.241 interface. Something that we talked about earlier is every
01:18:23.241 --> 01:18:26.815 property that's on the interface has to be on a class that
01:18:26.815 --> 01:18:30.026 implements that interface because the interface is a
01:18:30.026 --> 01:18:33.055 contract. And whenever you derive a class from an
01:18:33.055 --> 01:18:36.751 interface, you're basically signing that contract and saying
01:18:36.751 --> 01:18:39.720 my class will provide everything this interface.
01:18:39.800 --> 01:18:40.320 As it will.
01:18:41.090 --> 01:18:45.301 And so in that case I user model is implemented in the models and
01:18:45.301 --> 01:18:49.128 mapping layer models, contacts, user model and in this case
01:18:49.128 --> 01:18:52.956 we're gonna go into extend it again. Same deal as before if
01:18:52.956 --> 01:18:56.976 the extended file doesn't exist, you create it match the thing
01:18:56.976 --> 01:19:00.931 the name, just replace generated with extended match the name
01:19:00.931 --> 01:19:04.440 space match the class name. Don't forget your partial.
01:19:06.200 --> 01:19:09.492 I I can explain partials if we have time, but I doubt we will.
01:19:09.492 --> 01:19:12.000 And so then we'll go in here and we'll add our.
01:19:13.010 --> 01:19:15.400 Public int, number of orders.
01:19:17.450 --> 01:19:22.091 As of 2022.4, you have to have extra properties on these, so at
01:19:22.091 --> 01:19:25.210 the very least things like this read only.
01:19:27.400 --> 01:19:30.726 You can give this a default value of 0 and I want to say
01:19:30.726 --> 01:19:32.010 it's like data member.
01:19:32.840 --> 01:19:36.173 Emit default value equals false. You have to have a bunch of this
01:19:36.173 --> 01:19:39.152 extra step once this crying about OK never mind, I'm good.
01:19:39.152 --> 01:19:41.930 You have to have a bunch of extra stuff on here in the
01:19:41.930 --> 01:19:42.990 2022.4 unfortunately.
01:19:46.030 --> 01:19:50.170 And at the risk of making this really confusing.
01:19:52.570 --> 01:19:55.306 If you're ever not sure which ones you need, you can open one
01:19:55.306 --> 01:19:57.910 of these generated files and promptly like lose your mind.
01:19:58.530 --> 01:19:59.200 Umm.
01:20:02.060 --> 01:20:05.121 Here's all of the ones that are on this. I'm gonna tell you the
01:20:05.121 --> 01:20:07.130 ones that matter and the ones that don't.
01:20:08.960 --> 01:20:10.210 These two matter.
01:20:12.090 --> 01:20:13.180 The rest of these don't.
01:20:14.950 --> 01:20:18.620 Uh, so the rest of this stuff is?
01:20:19.470 --> 01:20:22.660 Cool and fine and you know, I guess good to have.
01:20:23.860 --> 01:20:25.150 But they really don't matter.
01:20:26.840 --> 01:20:28.950 So we don't even really need to worry about those.
01:20:32.370 --> 01:20:35.733 And your code just making sure that you have the basic ones of
01:20:35.733 --> 01:20:38.990 default value data member here read only. Also again doesn't
01:20:38.990 --> 01:20:42.246 matter, I'm just pointing down there cause the rest of these
01:20:42.246 --> 01:20:45.556 have them and it seems like it's probably there for a reason.
01:20:45.556 --> 01:20:48.973 Generally speaking, when you're writing back in code 90% of the
01:20:48.973 --> 01:20:52.390 time you're not doing something that nobody else has ever done.
01:20:53.440 --> 01:20:55.944 And you're following some kind of template or doing something
01:20:55.944 --> 01:20:58.449 that's already being done and you're just adding something to
01:20:58.449 --> 01:20:58.570 it.
01:21:00.050 --> 01:21:03.200 In that scenario, by all means copy paste.
01:21:04.620 --> 01:21:07.694 If you are not sure what you needed out of here or you were
01:21:07.694 --> 01:21:09.590 getting some kind of weird behavior.
01:21:10.640 --> 01:21:13.605 Nothing's gonna hurt to just copy all this stuff, paste it
01:21:13.605 --> 01:21:16.770 over here and then just rename whatever you need to rename and
01:21:16.770 --> 01:21:19.735 change things so that it makes sense and matches what it's
01:21:19.735 --> 01:21:22.650 supposed to be. I'm just gonna put these on here for now,
01:21:22.650 --> 01:21:24.710 because we're just doing a quick sample.
01:21:25.660 --> 01:21:26.090 OK.
01:21:27.130 --> 01:21:27.720 So.
01:21:29.150 --> 01:21:32.735 Uh, now we have a number of orders on the interface and
01:21:32.735 --> 01:21:36.512 we've implemented that value or that variable on the class
01:21:36.512 --> 01:21:36.960 itself.
01:21:38.730 --> 01:21:43.153 The user model class right here. This class is the one that
01:21:43.153 --> 01:21:47.577 actually drives that T4 that generates the like DTO classes
01:21:47.577 --> 01:21:48.830 on the front end.
01:21:50.210 --> 01:21:53.548 Now, once you've made your change again, let's let's just
01:21:53.548 --> 01:21:57.288 pretend that some other back end developer has written the logic
01:21:57.288 --> 01:22:00.857 that's going to fill this out with the real number of orders.
01:22:00.857 --> 01:22:04.425 This user's place. I won't show how to do all that right now,
01:22:04.425 --> 01:22:07.705 but assuming some developers already done that, what you
01:22:07.705 --> 01:22:11.158 would do to get this on the front end, most critically, you
01:22:11.158 --> 01:22:14.438 need to rebuild the solution. And the reason for that is
01:22:14.438 --> 01:22:18.006 because the T fours and all the automatic code generation, it
01:22:18.006 --> 01:22:19.560 does not analyze the raw C.
01:22:19.670 --> 01:22:23.674 Code it does not work on physically written files. It
01:22:23.674 --> 01:22:28.049 looks at the output of the build, it reads the DLLS and it
01:22:28.049 --> 01:22:31.979 uses a C# feature called reflection on those DLLS to
01:22:31.979 --> 01:22:36.799 understand what code it needs to generate and So what that means
01:22:36.799 --> 01:22:41.545 to to trim all the crap from the sentence I just said is if you
01:22:41.545 --> 01:22:46.291 don't build your changes won't be in the T4. So I haven't built
01:22:46.291 --> 01:22:49.850 anything right now. And if I go and run the T4.
01:22:50.080 --> 01:22:53.490 This property is not gonna be in here, but after I build and
01:22:53.490 --> 01:22:57.179 needs to be a full rebuild. When I run the T4, this property will
01:22:57.179 --> 01:22:57.850 be in there.
01:22:59.880 --> 01:23:03.622 So I keep saying the T4 and this scenario, I'm going to assume
01:23:03.622 --> 01:23:07.127 that you want this on like the React storefront. So the T4
01:23:07.127 --> 01:23:10.869 that's relevant to that. Let's pretend I've already rebuilt. I
01:23:10.869 --> 01:23:14.374 don't want to because it takes like 3 or 4 minutes and you
01:23:14.374 --> 01:23:18.057 know, we got 10 minutes left. So, but let's pretend I've done
01:23:18.057 --> 01:23:18.710 my rebuild.
01:23:20.730 --> 01:23:24.853 In full Visual Studio you can go to the 07 portals folder and
01:23:24.853 --> 01:23:26.050 store front react.
01:23:26.750 --> 01:23:31.529 And source API and there it is CV API dot TT you right click on
01:23:31.529 --> 01:23:36.010 this file and it has a run custom tool option for you guys.
01:23:36.010 --> 01:23:40.490 If you've never run at 4 before which odds are you haven't.
01:23:41.790 --> 01:23:44.125 Michael, you you probably have you been here a while and you
01:23:44.125 --> 01:23:46.231 worked on X portal, so you you've probably run Alex, I
01:23:46.231 --> 01:23:47.380 don't know if you have or not.
01:23:48.090 --> 01:23:48.860 I have.
01:23:49.050 --> 01:23:51.692 OK, cool. Even better. Well, then you know that the first
01:23:51.692 --> 01:23:54.334 time you click this, it's gonna give you a little warning
01:23:54.334 --> 01:23:57.295 message. Message that says like, hey, Are you sure you wanna run
01:23:57.295 --> 01:23:58.980 this? It could kill you or whatever.
01:24:00.570 --> 01:24:03.995 Uh, you can just check the box and never show that again and
01:24:03.995 --> 01:24:04.500 click OK.
01:24:06.690 --> 01:24:07.350 And.
01:24:08.900 --> 01:24:13.642 And then run custom tool and again pretend pretending that
01:24:13.642 --> 01:24:18.465 I've done my build. If I ran this, it would actually go and
01:24:18.465 --> 01:24:23.207 add number of orders on to the user in DTO CVA API dot DTO
01:24:23.207 --> 01:24:23.850 classes.
01:24:24.940 --> 01:24:28.960 So I would modify user model in here.
01:24:25.340 --> 01:24:27.660 A cool tip.
01:24:30.790 --> 01:24:35.124 Cool tip. If you don't memorize that path because I haven't
01:24:35.124 --> 01:24:39.819 really necessarily memorized the path. I just use the filter bar
01:24:39.819 --> 01:24:43.430 above the solution explorer and just do a dot TT.
01:24:39.880 --> 01:24:40.390 Yep.
01:24:41.420 --> 01:24:44.720 Yeah, up here at the very top, it says, uh, search solution.
01:24:44.720 --> 01:24:48.075 Explorer dot TT will find you all the T fours in the solution
01:24:48.075 --> 01:24:51.322 and you can just scroll until you find the one that's under
01:24:51.322 --> 01:24:53.540 storefront dot react. Look, there it is.
01:24:55.510 --> 01:25:00.007 Very cool. Saves you some time the the admin front end one is
01:25:00.007 --> 01:25:04.795 also under admin dot Anja CV API dot T you guys don't really ever
01:25:04.795 --> 01:25:09.220 need to worry about these other T fours. These are just the.
01:25:10.130 --> 01:25:13.117 These are only needed if you actually add new database
01:25:13.117 --> 01:25:16.322 tables, which if you guys are doing that again you'll need
01:25:16.322 --> 01:25:17.680 more than just this like.
01:25:18.330 --> 01:25:21.748 Uh, this giant info dump in an hour and a half, you'll you
01:25:21.748 --> 01:25:25.049 know, at that point you'll you'll need a little bit more
01:25:25.049 --> 01:25:28.641 like hands on type of training and things like that. At which
01:25:28.641 --> 01:25:32.175 point we go over these for you guys. If you're just adding a
01:25:32.175 --> 01:25:35.940 property to something or like as as does happen sometimes not as
01:25:35.940 --> 01:25:39.705 much as I used to, but this does still happen sometimes, maybe a
01:25:39.705 --> 01:25:43.239 back end or was like, yeah, I made an endpoint for you. It's
01:25:43.239 --> 01:25:43.760 gonna be.
01:25:44.460 --> 01:25:47.976 It's gonna be right here and you don't see it in CV API dot
01:25:47.976 --> 01:25:51.493 whatever for some reason. Then you can come back here again
01:25:51.493 --> 01:25:55.185 after a full rebuild and you can run the CVP IT4AS yourself at
01:25:55.185 --> 01:25:58.995 that point, if you don't see the endpoint still and you've built
01:25:58.995 --> 01:26:02.453 and ran this, and you can actually see the endpoint in the
01:26:02.453 --> 01:26:04.680 C# code, but you don't see it in the.
01:26:05.280 --> 01:26:09.117 The front end stuff at that point you you'd probably wanna
01:26:09.117 --> 01:26:13.344 kick it back to the back end and say, hey, I ran the T fours and
01:26:13.344 --> 01:26:14.320 I don't see it.
01:26:16.140 --> 01:26:18.210 Your endpoints probably broken or something.
01:26:19.970 --> 01:26:23.140 And I can actually really quickly, I'm assuming that
01:26:23.140 --> 01:26:26.968 answers your questions, Alex, on on what you were asking and if
01:26:26.968 --> 01:26:30.916 so, I can actually show you guys very quickly how to troubleshoot
01:26:30.916 --> 01:26:34.266 why and endpoint might not be showing up in like in the
01:26:34.266 --> 01:26:36.120 storefront and stuff like that.
01:26:37.920 --> 01:26:40.942 I was just going to ask about the there's a file called like
01:26:40.942 --> 01:26:43.964 used in addendums that I've had to add something to. Is that
01:26:43.860 --> 01:26:44.510 Yep.
01:26:43.964 --> 01:26:46.838 related to what we're talking about, or is that something
01:26:46.510 --> 01:26:51.330 That is, that is exactly related to what we're talking about.
01:26:46.838 --> 01:26:47.730 totally different?
01:26:51.330 --> 01:26:52.030 Yeah, so.
01:26:53.650 --> 01:26:57.185 Yeah. So I'll I'll quickly get dig into what that that file
01:26:57.185 --> 01:27:00.484 actually means. So you've noticed whenever you set up a
01:27:00.484 --> 01:27:03.784 self local or when you're looking at like API calls, we
01:27:03.784 --> 01:27:07.260 have API, storefront and API admin and if you know, like I
01:27:07.260 --> 01:27:11.089 said, Michael's been on projects that use X portal. So he's seen
01:27:11.089 --> 01:27:14.330 API brand admin, but there's all these different APIs.
01:27:14.830 --> 01:27:20.142 Umm. In order to reduce load time at some point in in in
01:27:20.142 --> 01:27:26.199 years past, a decision was made to mark endpoints with which API
01:27:26.199 --> 01:27:27.410 they load in.
01:27:28.640 --> 01:27:32.395 And that's what they used in storefront does and used in
01:27:32.395 --> 01:27:36.216 addendums, is where you put those. If an endpoint doesn't
01:27:36.216 --> 01:27:40.037 have used in storefront #1 hitting that endpoint from the
01:27:40.037 --> 01:27:44.253 API storefront application will 404 and #2 the T fours will not
01:27:44.253 --> 01:27:47.020 generate it in your CV API file. So let's
01:27:47.770 --> 01:27:51.890 uh, let me make an example in point here. I'm just gonna open
01:27:51.890 --> 01:27:55.877 up one of these random extended files and. OK, so endpoints
01:27:55.877 --> 01:27:59.798 typically look like this public class do some action. They
01:27:59.798 --> 01:28:04.184 always have an eye return, let's say at this one just returns the
01:28:04.184 --> 01:28:05.380 string. Who cares?
01:28:06.730 --> 01:28:09.380 And it requires you to pass in.
01:28:10.210 --> 01:28:12.200 Uh, an input that is a string.
01:28:12.980 --> 01:28:13.260 Alright.
01:28:13.950 --> 01:28:15.830 Always have to have this stuff on here.
01:28:16.750 --> 01:28:18.980 Accounts something.
01:28:19.840 --> 01:28:25.390 Do the thing and it's a post. OK, So what I've done here?
01:28:26.150 --> 01:28:29.170 I've defined an endpoint called do some action.
01:28:29.900 --> 01:28:32.891 I've given it a route. I've said that it's a post request and
01:28:32.891 --> 01:28:35.690 I've said it required it doesn't require, but it accepts.
01:28:36.560 --> 01:28:41.021 And input a string called input on the body of the request.
01:28:41.021 --> 01:28:45.630 Right? Cool. This endpoint will not be in any front end code.
01:28:46.480 --> 01:28:51.320 Because it does not have a used in a anything on it.
01:28:52.000 --> 01:28:52.660 Umm.
01:28:53.960 --> 01:28:57.116 I won't. I'll talk about these ones in just a minute. You'll
01:28:57.116 --> 01:28:59.806 notice that these also technically don't, but we'll
01:28:59.806 --> 01:29:01.100 talk about that in a SEC.
01:29:02.660 --> 01:29:06.460 So if I wanted this to be on the storefront, it would be used in.
01:29:07.320 --> 01:29:11.623 Storefront and now this will if I were to rebuild and run that
01:29:11.623 --> 01:29:15.722 React Storefront 4 do some action would be generated in the
01:29:15.722 --> 01:29:16.610 CV API files.
01:29:19.640 --> 01:29:22.750 So generally speaking.
01:29:23.950 --> 01:29:27.182 Moving on to talking about these, as I said, I would and
01:29:27.182 --> 01:29:30.300 getting to your question about the used and addendums.
01:29:31.730 --> 01:29:35.270 Generally speaking, we've moved away from defining what?
01:29:36.110 --> 01:29:39.946 API and endpoint is defined. There is allowed in on the
01:29:39.946 --> 01:29:44.261 actual endpoint definition. Here we've kind of moved away from
01:29:44.261 --> 01:29:48.577 that process and we now use the used in addendum files so that
01:29:48.577 --> 01:29:50.700 all that stuff is in one place.
01:29:51.790 --> 01:29:52.240 I.
01:29:53.090 --> 01:29:55.420 Don't care really.
01:29:56.000 --> 01:29:59.604 Umm, I still make endpoints that just say used in storefront on
01:29:59.604 --> 01:30:02.870 them, because I think it's easier to it's easier to read.
01:30:04.030 --> 01:30:08.102 But uh, the proper practice technically would be to make
01:30:08.102 --> 01:30:12.531 this a partial class, and then over here in used in addendums
01:30:12.531 --> 01:30:17.031 dot storefront. What I call it do some action. OK, we gotta go
01:30:17.031 --> 01:30:20.460 find alphabetically where the word do would go.
01:30:21.520 --> 01:30:25.950 After all these deletes and then you had used in store front.
01:30:27.660 --> 01:30:28.480 I.
01:30:30.260 --> 01:30:30.800 Yeah.
01:30:31.940 --> 01:30:37.568 Hypo Public partial class do some action because that's what
01:30:37.568 --> 01:30:39.690 oopsies just like that.
01:30:41.570 --> 01:30:45.473 Again, if you guys wanna bonus I'll I'll take 5 minutes and
01:30:45.473 --> 01:30:49.571 explain what partial does cause it's kind of cool but now this
01:30:49.571 --> 01:30:53.605 has a used in storefront. If you're trying to find everything
01:30:53.605 --> 01:30:57.573 that this class does and every relevant piece of it, you can
01:30:57.573 --> 01:31:01.671 click on me. Personally I have code lens on James turns it off
01:31:01.671 --> 01:31:05.704 for most people. If he helps you set up your local. I like to
01:31:05.704 --> 01:31:06.420 have it on.
01:31:06.980 --> 01:31:10.483 Umm, because you can click on it and you can just see. Ohh this
01:31:10.483 --> 01:31:13.876 is used in admin and it has used in storefront. Great, that's
01:31:13.876 --> 01:31:14.150 easy.
01:31:15.280 --> 01:31:17.910 Umm so.
01:31:22.850 --> 01:31:26.085 Yeah, I I personally like this. If you don't have this on,
01:31:26.085 --> 01:31:29.704 you're going to turn it back on. It's called code lens or you can
01:31:29.704 --> 01:31:33.213 get to similar effect by right clicking a like the the the name
01:31:33.213 --> 01:31:35.790 of the class and clicking find all references.
01:31:37.560 --> 01:31:41.176 And it totally didn't find all references. That's awesome.
01:31:41.176 --> 01:31:42.340 Thank you for that.
01:31:43.900 --> 01:31:44.870 Find all references.
01:31:46.980 --> 01:31:47.490 Huh.
01:31:48.630 --> 01:31:49.000 Wow.
01:31:49.740 --> 01:31:52.839 That sucks. That's weird. I normally it would show me the
01:31:52.839 --> 01:31:55.350 other two places that it's being used as well.
01:31:58.350 --> 01:31:59.460 Is there any other?
01:32:00.310 --> 01:32:04.208 Yeah. OK. Well, that's just one more reason that code lens is
01:32:04.208 --> 01:32:05.340 actually good. UM.
01:32:06.640 --> 01:32:07.130 Anyway.
01:32:08.060 --> 01:32:12.210 Uh, worst case you can always like search it over here.
01:32:14.160 --> 01:32:17.430 Paste this name in here. Find it and all the places that it's in.
01:32:18.820 --> 01:32:19.760 And.
01:32:24.260 --> 01:32:25.970 OK, never mind that still didn't really.
01:32:28.030 --> 01:32:30.948 That still didn't really help me, did it? And that's wild, I
01:32:30.948 --> 01:32:32.240 guess it's still searching.
01:32:35.390 --> 01:32:38.851 Nate well anyway, code lens is cool. I like code lens. Some
01:32:38.851 --> 01:32:41.100 people don't like code lens, but I do.
01:32:43.430 --> 01:32:44.260 OK so.
01:32:46.820 --> 01:32:50.201 That OK. There we go. It only took forever. But you can now
01:32:50.201 --> 01:32:53.581 see used in admin and used in store front and a much slower
01:32:53.581 --> 01:32:55.610 and more tedious UI than code lens.
01:32:56.900 --> 01:32:59.410 I'm sick.
01:33:00.930 --> 01:33:05.267 OK, so bonus round this one doesn't really matter for it's
01:33:05.267 --> 01:33:09.899 not assessed specific thing. A lot of the stuff I talked about
01:33:09.899 --> 01:33:14.383 as specific, this is just the cool C feature that I think is
01:33:14.383 --> 01:33:18.353 neat. C supports a feature called partial classes and
01:33:18.353 --> 01:33:19.750 partial interfaces.
01:33:20.510 --> 01:33:21.080 UM.
01:33:22.630 --> 01:33:26.395 It's basically like being allowed to define all the
01:33:26.395 --> 01:33:30.523 different pieces of a class or an interface in different
01:33:30.523 --> 01:33:34.289 places. Now there are limitations to this and those
01:33:34.289 --> 01:33:38.923 limitations make perfect sense when I explain them, you'll make
01:33:38.923 --> 01:33:42.761 sense, but there are those limitations. So what that
01:33:42.761 --> 01:33:47.395 actually means is that I can do. Let me start with this example
01:33:47.395 --> 01:33:47.830 first.
01:33:50.290 --> 01:33:51.910 Once again, we love the word sample.
01:33:54.880 --> 01:33:58.660 Cool. And then another class called Sample with.
01:33:59.600 --> 01:34:00.240 Name.
01:34:01.140 --> 01:34:04.186 Well, that's not going to work. And also sometimes brackets
01:34:04.186 --> 01:34:07.436 disappear. There we go. That's not gonna work because these are
01:34:07.436 --> 01:34:10.279 both called sample and unfortunately the error that was
01:34:10.279 --> 01:34:13.377 there for a second went away. There it is and it'll tell you
01:34:13.377 --> 01:34:16.220 the namespace already contains a definition for sample.
01:34:17.600 --> 01:34:21.163 Ultimately what I want is I want to be able to do something like
01:34:21.163 --> 01:34:22.040 this you sample.
01:34:23.150 --> 01:34:26.969 Sample dot ID equals 1 sample dot name equals stuff. Right?
01:34:26.969 --> 01:34:30.725 Cool. That's what I wanna be able to do, but it doesn't. I
01:34:30.725 --> 01:34:34.545 can't do it here. Doesn't work like this cuz it's trying to
01:34:34.545 --> 01:34:36.900 treat these as two separate classes.
01:34:37.630 --> 01:34:38.560 Well, you can do.
01:34:39.700 --> 01:34:43.560 Is before the word class. You can add partial.
01:34:44.370 --> 01:34:45.060 And now?
01:34:46.400 --> 01:34:50.012 Oops, that's supposed to be a string, not a. Yeah string, not
01:34:50.012 --> 01:34:53.682 net. And we'll make it noble so that that error goes away. And
01:34:53.682 --> 01:34:57.177 now it works. Now it treats this class these two classes as
01:34:57.177 --> 01:34:57.760 basically.
01:34:58.640 --> 01:35:00.750 The same class and it's as if.
01:35:01.650 --> 01:35:05.284 This wasn't here and that I just had one definition for it. The
01:35:05.284 --> 01:35:08.804 nice thing about it is that it allows you to define different
01:35:08.804 --> 01:35:12.325 pieces of a class in separate files, which can be really nice
01:35:12.325 --> 01:35:13.290 if you have like.
01:35:14.070 --> 01:35:17.580 A lot of stuff that's dumped into one class. You can use
01:35:17.580 --> 01:35:21.583 partials and separate them into different files to kind of break
01:35:21.583 --> 01:35:24.600 your code apart and keep relevant code together.
01:35:26.210 --> 01:35:28.830 It's just nice for code cleanliness now.
01:35:29.470 --> 01:35:32.670 The limitation, the primary limitation of a partial.
01:35:33.660 --> 01:35:38.993 Anything interface or class is you cannot define different
01:35:38.993 --> 01:35:40.620 pieces of a class.
01:35:41.420 --> 01:35:42.970 It different assemblies.
01:35:44.800 --> 01:35:47.776 Without getting overly complicated and and and
01:35:47.776 --> 01:35:51.638 technical this that limitation effectively boils down to you
01:35:51.638 --> 01:35:55.500 can't have different pieces of the same partial in different
01:35:55.500 --> 01:35:59.045 projects, so each of these little top level things that
01:35:59.045 --> 01:36:03.097 have files inside them, not the folders but the like the pieces
01:36:03.097 --> 01:36:05.440 inside the folders are the projects.
01:36:03.430 --> 01:36:03.680 But.
01:36:07.760 --> 01:36:09.100 Every project.
01:36:09.770 --> 01:36:13.762 When the compiler is done running the C# code is converted
01:36:13.762 --> 01:36:17.821 from C# and a project into what's called an assembly. A DLL
01:36:17.821 --> 01:36:22.151 file you're familiar with DLS. You've probably seen a bajillion
01:36:22.151 --> 01:36:23.640 of them at this point.
01:36:24.880 --> 01:36:29.360 But every individual project generates an assembly.
01:36:30.710 --> 01:36:34.400 And obviously the reason that you can't have.
01:36:35.190 --> 01:36:35.780 A.
01:36:37.610 --> 01:36:41.264 Partial across assemblies is because how that that that
01:36:41.264 --> 01:36:45.178 couldn't possibly make sense, right? You can't have half of
01:36:45.178 --> 01:36:48.963 the implementation defined in one assembly and half of it
01:36:48.963 --> 01:36:50.920 defined in the other assembly.
01:36:51.610 --> 01:36:55.260 And then somehow have the build process go. Ohh yeah OK so.
01:36:57.160 --> 01:37:03.042 Assembly A has partial Class B in it and assembly C has partial
01:37:03.042 --> 01:37:08.648 Class B in it. OK, I need to build a assembly a before I can
01:37:08.648 --> 01:37:10.210 build assembly C.
01:37:11.250 --> 01:37:15.156 But they both are trying to define some piece of the same
01:37:15.156 --> 01:37:19.129 class. So how does it know which one to build first? It it
01:37:19.129 --> 01:37:22.900 there's no way it, it just couldn't, so that's that's a
01:37:22.900 --> 01:37:27.008 limitation that you personally will probably never run into.
01:37:27.008 --> 01:37:28.490 But if you do, that's.
01:37:30.100 --> 01:37:33.560 That's the primary limitation to to partials so.
01:37:37.050 --> 01:37:37.420 Cool.
01:37:38.320 --> 01:37:40.310 Yeah, I know the name on a partial makes sense.
01:37:38.500 --> 01:37:39.740 So yeah.
01:37:40.950 --> 01:37:43.990 It's actually part of a class.
01:37:44.440 --> 01:37:44.650 Yep.
01:37:48.310 --> 01:37:51.501 And that it's all containerized, almost into its own scope for
01:37:51.501 --> 01:37:52.160 each project.
01:37:53.820 --> 01:37:54.880 Indeed.
01:37:55.760 --> 01:37:56.390 Nice.
01:37:56.420 --> 01:37:57.490 Very cool stuff.
01:37:59.170 --> 01:38:02.825 Yeah, hopefully you guys got some, some decent mileage out of
01:38:02.825 --> 01:38:03.120 this.
01:38:04.900 --> 01:38:05.770 We're.
01:38:07.860 --> 01:38:10.814 Hopefully the the back and there's also got wheelchair
01:38:10.814 --> 01:38:11.190 theirs.
01:38:12.480 --> 01:38:12.760 Eat.
01:38:13.610 --> 01:38:15.220 Over this I'm gonna start.
01:38:17.400 --> 01:38:20.450 I don't know would be funny. Mess with them. Be like you're
01:38:20.450 --> 01:38:21.670 all founders now, right?
01:38:24.170 --> 01:38:24.880 Get the girl.
01:38:24.350 --> 01:38:27.882 I see they've gone into a E prevent default for form
01:38:27.882 --> 01:38:31.880 submissions, so I'm sure they're having a lot of fun there.
01:38:30.700 --> 01:38:34.349 OK, cool. They they got into the they got into the weeds a little
01:38:34.349 --> 01:38:34.570 bit.
01:38:36.040 --> 01:38:37.370 Well, the fun thing is.
01:38:39.010 --> 01:38:43.290 If you guys, if you guys can can crystallize some of that link
01:38:43.290 --> 01:38:43.970 knowledge.
01:38:45.490 --> 01:38:49.426 And get good at Lync. You'll probably be better at writing
01:38:49.426 --> 01:38:49.960 queries.
01:38:50.660 --> 01:38:54.058 Then you'll be you'll be about on par with the average back and
01:38:54.058 --> 01:38:55.120 in terms of writing.
01:38:55.790 --> 01:38:59.320 Like database queries, which is, you know, that's pretty cool.
01:39:00.380 --> 01:39:00.920 Umm.
01:39:02.230 --> 01:39:03.320 I uh.
01:39:02.550 --> 01:39:05.820 The analogy between like the link.
01:39:06.540 --> 01:39:10.462 Uh. Keywords and filter and map that that was huge that really
01:39:10.462 --> 01:39:14.322 like bridged the A gap. So that was a great anything. Anytime
01:39:10.540 --> 01:39:11.150 Yeah.
01:39:12.940 --> 01:39:13.430 Yeah.
01:39:14.322 --> 01:39:17.933 you like make the analogy between JavaScript and and back
01:39:14.450 --> 01:39:15.270 Uh.
01:39:17.933 --> 01:39:21.606 end code it really helps me learn. So I appreciate the way
01:39:21.606 --> 01:39:23.100 you did that. Very nice.
01:39:22.260 --> 01:39:25.740 Yeah, one more. One more nugget of those.
01:39:27.420 --> 01:39:32.060 Flat map in JavaScript is the same as select Many Inc, which
01:39:32.060 --> 01:39:36.852 is one that you'll probably use less frequently in both sides.
01:39:36.852 --> 01:39:41.720 You I don't know if you've ever used flat map in JavaScript and
01:39:41.720 --> 01:39:46.512 I very rarely use select many Inc like once in a blue moon few
01:39:46.512 --> 01:39:48.490 times a year type of deal.
01:39:49.830 --> 01:39:52.540 But it basically allows you to.
01:39:54.050 --> 01:39:57.120 If I can get a cool example here really really fast.
01:39:58.850 --> 01:40:02.690 Don't text, so I'll W.
01:40:04.870 --> 01:40:07.320 OK, so accounts.
01:40:08.980 --> 01:40:14.621 Have multiple addresses on them. That's your address book account
01:40:14.621 --> 01:40:18.980 contacts, right? If I wanted to select all of the.
01:40:20.910 --> 01:40:25.816 All of the address book entries on every account that matches
01:40:25.816 --> 01:40:30.010 some query. So let's say that I want accounts where.
01:40:30.480 --> 01:40:31.490 Uh.
01:40:33.220 --> 01:40:37.351 Where their credit balance is less than or equal to 0, so they
01:40:37.351 --> 01:40:41.482 have no available credit. Right now I want to find the billing
01:40:41.482 --> 01:40:42.990 address of all of them.
01:40:44.260 --> 01:40:49.339 Uh, so as of right now, I have the all accounts where credit is
01:40:49.339 --> 01:40:53.863 less than equal 0. This is effective like a select star.
01:40:53.863 --> 01:40:55.530 OK, so I need to get.
01:40:56.170 --> 01:40:59.515 There uh account contacts, so I'm just going to do a select
01:40:59.515 --> 01:40:59.850 right?
01:41:00.540 --> 01:41:03.140 Cool. Let me do VAR query equals.
01:41:04.060 --> 01:41:07.346 You would you would expect at this point that the query is
01:41:07.346 --> 01:41:10.744 returning and I queryable of account contacts. However it is
01:41:10.744 --> 01:41:13.863 not. It's returning an I queryable of an icollection of
01:41:13.863 --> 01:41:16.983 account contacts. This will actually throw an exception
01:41:16.983 --> 01:41:20.603 because LINQ to entities doesn't understand that it doesn't know
01:41:20.603 --> 01:41:22.330 how to query a query basically.
01:41:23.050 --> 01:41:26.390 And So what you have to do is if you're.
01:41:27.130 --> 01:41:31.425 Return type here is a collection of things, an eye collection and
01:41:31.425 --> 01:41:35.395 I enumerable a list, anything like that. Then you use select
01:41:35.395 --> 01:41:35.720 many.
01:41:36.610 --> 01:41:38.280 And now the return type is in.
01:41:39.590 --> 01:41:43.257 Stick with me. Come out. There we go. I queryable of account
01:41:43.257 --> 01:41:46.804 contacts. Exactly as you would expect. So effectively it's
01:41:46.804 --> 01:41:49.870 saying select the list of these on every matching.
01:41:50.680 --> 01:41:55.043 Part of the query coming before it and then flatten all of them
01:41:55.043 --> 01:41:58.997 into one list instead of it being a list of lists, right?
01:41:58.997 --> 01:42:03.223 And then the rest of the query would be like, where X6 dot is
01:42:03.223 --> 01:42:07.450 billing select, it's not slave which is the contact two list.
01:42:08.090 --> 01:42:10.740 Uh, and this is now a list of contacts.
01:42:11.880 --> 01:42:16.174 So now I have the the billing contact of every account whose
01:42:16.174 --> 01:42:20.186 credit balance is less than or equal to 0 and that's the
01:42:20.186 --> 01:42:22.790 scenario we're selecting many works.
01:42:23.400 --> 01:42:27.268 JavaScript flat map is exactly the same way. If you were to
01:42:27.268 --> 01:42:30.942 call map on something in JavaScript that returns a list,
01:42:30.942 --> 01:42:35.003 then you would get an array of arrays, whereas if you flat map
01:42:35.003 --> 01:42:38.420 it'll just take. It's basically the same as like if.
01:42:40.290 --> 01:42:40.830 Umm.
01:42:41.630 --> 01:42:45.213 You can think of flat map or select many as being similar to
01:42:45.213 --> 01:42:46.740 like uh, that's read only.
01:42:49.260 --> 01:42:51.300 It's like, let's say that we have like a.
01:42:53.520 --> 01:42:55.050 Can't success equals?
01:42:56.210 --> 01:42:59.040 They've got an array of objects with.
01:43:02.540 --> 01:43:04.010 Three like that.
01:43:05.120 --> 01:43:07.550 And then another object that's like.
01:43:09.160 --> 01:43:13.350 246 I don't know. It's making stuff up right.
01:43:14.830 --> 01:43:18.280 And you were to do test like ours?
01:43:19.230 --> 01:43:20.890 Equals test dot map.
01:43:22.140 --> 01:43:27.340 Dot R Right, this is gonna be an array of arrays. UM.
01:43:28.100 --> 01:43:32.138 And effectively flat map if which we can do flat map right
01:43:32.138 --> 01:43:36.586 here. Now it's just a flat array of numbers if intelligence will
01:43:36.586 --> 01:43:41.035 catch up with me. Yep. And this array would then be 123246. Just
01:43:41.035 --> 01:43:45.278 all those numbers all in one array. It's effectively the same
01:43:45.278 --> 01:43:47.810 as if you were to do map dot reduce.
01:43:49.700 --> 01:43:52.240 And it would be like previous current.
01:43:53.530 --> 01:43:56.220 Dot dot dot previous dot dot dot current.
01:43:57.000 --> 01:44:00.892 And your input would be an empty array, right? That's the same
01:44:00.892 --> 01:44:04.351 behavior as flat map. It's basically just spreading the
01:44:04.351 --> 01:44:08.119 contents of every array into a top level array that contains
01:44:08.119 --> 01:44:11.270 all of them. That's what select Mini does as well.
01:44:15.560 --> 01:44:16.990 Good, good analogy.
01:44:21.640 --> 01:44:23.080 Science rules.
01:44:24.260 --> 01:44:25.360 Hmm.
01:44:25.050 --> 01:44:27.800 I saw Bill Nye live once. Fun fact.
01:44:28.170 --> 01:44:29.090 Yeah, that's awesome.
01:44:29.450 --> 01:44:30.420 It was amazing.
01:44:30.930 --> 01:44:31.820 I'm jealous.
01:44:33.920 --> 01:44:37.190 I say science rules way too much for somebody that's never seen
01:44:37.190 --> 01:44:37.650 him live.
01:44:40.260 --> 01:44:40.420 Well.
01:44:40.500 --> 01:44:44.120 If you watch them on TV as a kid, it it he's there in spirit
01:44:40.570 --> 01:44:41.800 I'm a fake fan.
01:44:40.600 --> 01:44:41.620 Why do you need to?
01:44:44.120 --> 01:44:45.010 with all of us.
01:44:45.260 --> 01:44:46.230 True.
01:44:48.680 --> 01:44:49.590 Well, alright.
01:44:50.750 --> 01:44:51.680 That was fun.
01:44:52.920 --> 01:44:53.660 Uh.
01:44:55.180 --> 01:44:59.426 If you guys, if you guys find any other stuff back in wise
01:44:59.426 --> 01:45:00.290 that you're.
01:45:01.160 --> 01:45:02.270 Unsure of.