Repository navigation
C Programming Intermediate Lecture 9 Unique Constraints in Databases Entity Framework Sorting
C# Programming (Intermediate) - Lecture 9: Unique Constraints in Databases, Entity Framework Sorting
Full tutorial link > https://www.youtube.com/watch?v=Tb-w0b7Lf0A
C# Programming (Advanced/Intermediate) Lectures (9/14) will teach you #CSharp #programming from beginner to intermediate/expert level. This course is an excellent source to learn advanced concepts in C# #coding. If you are a beginner to C#, watch our previous course lectures. The playlist link of the previous course is below.
Full playlist of the previous course: C# For Beginners
https://www.youtube.com/playlist?list=PL_pbwdIyffskoSXySh0MdiayPJsBZ7m2o
Discord ➡️ https://bit.ly/SECoursesDiscord
Patreon ➡️ https://www.patreon.com/SECourses
Technology Playlist (30+ Tutorial / Guide / News / Review Videos)
https://www.youtube.com/playlist?list=PL_pbwdIyffsnkay6X91BWb9rrfLATUMr3
Stable Diffusion Playlist (30+ Tutorial / Guide Videos)
https://www.youtube.com/playlist?list=PL_pbwdIyffsmclLl0O144nQRnezKlNdx3
Please join discord, mention me and ask me any questions. Thank you for like, subscribe, share and Patreon support. I am open to private consulting with Patreon subscription.
Full playlist of this course
https://www.youtube.com/playlist?list=PL_pbwdIyffslHaBdS3RUW26RKzSjkl8m4
You can watch for free our C# Programming, ASP .NET Core MVC programming, Machine Learning and Software Engineering related courses on our playlists page
https://www.youtube.com/@SECourses/playlists
GitHub code repository of this course (source codes of the lectures)
https://github.com/FurkanGozukara/Introduction-to-Programming-2-2021
In Lecture 9:
-
How to hide and display a tab according to the authority of the logged-in user
-
How to load a ready CSV dataset into the database with Entity Framework
-
How to utilize task.factory to prevent user interface freeze
-
How to update label from sub-threads, sub-tasks with dispatcher
-
How to add uniqueness constraint to a database table with defining a unique index
-
How to achieve unique adding to the database when using entity framework
-
How to add sorting feature to your datagrid display when using entity framework for automatic display, insert, update, delete
-
How to bind all elements of an enumeration to a combobox
-
How to display description of enum items in the combobox
-
How to get selected enumeration of itemssource bound combobox
Introduction
In software development, it is essential to have a good grasp of various techniques and tools that can help us in developing robust and efficient applications. This article will cover various topics related to software development, such as hiding and displaying a tab, loading a CSV dataset into a database, utilizing Task.Factory, updating a label from sub-threads, adding uniqueness constraints to a database table, achieving unique adding to a database when using Entity Framework, adding sorting feature to datagrid display, binding all elements of an enumeration to a combobox, displaying descriptions of enum items in a combobox, and getting the selected enumeration of items source-bound combobox.
How to Hide and Display a Tab According to the Authority of the Logged-in User
In software development, it is essential to manage user privileges to ensure that users can only access features that they are authorized to use. In WPF, we can use the IsEnabled and Visibility properties to hide or display a tab based on the authority of the logged-in user. We can define the authority of the user in the database, and based on that, we can enable or disable the tab as required. This technique helps to prevent unauthorized access to sensitive data and functionality.
How to Load a Ready CSV Dataset into the Database with Entity Framework
CSV (Comma Separated Values) is a popular format for storing data in a tabular format. In software development, we often need to load CSV data into a database for further analysis or processing. Entity Framework is a popular Object-Relational Mapping (ORM) tool that allows us to work with databases using C# code. We can use Entity Framework to load a ready CSV dataset into the database by creating a model that maps the CSV data to the database table, and then using the DbContext class to add the data to the table.
How to Utilize Task.Factory to Prevent User Interface Freeze
In software development, it is essential to ensure that the user interface remains responsive even when the application is performing heavy processing tasks. We can use Task.Factory to run time-consuming tasks asynchronously and prevent the user interface from freezing. Task.Factory allows us to run tasks on a separate thread and then update the user interface when the task is complete. This technique helps to provide a better user experience and improves the overall performance of the application.
How to Update Label from Sub-Threads, Sub-Tasks with Dispatcher
In WPF, we can use the Dispatcher class to update the user interface from sub-threads or sub-tasks. When a task or thread that is not the UI thread attempts to update the user interface, an exception is thrown. We can use the Dispatcher.BeginInvoke
-
00:00:02 Hello dear students, welcome to the lecture 9 of introduction to programming 2 AKA Advanced
-
00:00:07 programming. So today, today we will continue from our previous lecture. I will start with
-
00:00:14 a cloning our lecture 8 code, as usual
-
00:00:36 And meanwhile, it's also open our secret managers.
-
00:00:39 Server management Studio.
-
00:00:53 So if you are remembering Weaver's building, a patient management system and at the previous
-
00:01:03 lectures, we had built how an interface to update delete or insert drugs.
-
00:01:14 With using a fully autonomous Entity Framework.
-
00:01:22 Okay.
-
00:01:24 So, let's rename this to lecture 9.
-
00:01:37 If you have any questions regarding to our course lectures, please ask them to me Discord
-
00:01:46 channel so that I can answer them in the lecture video or in the Disco Channel. You don't have
-
00:01:55 to be necessarily taking my course. You don't have to be a student of our University, you
-
00:02:02 can ask me as you want.
-
00:02:07 You can ask them through our score Channel. Also your feedback could help me to improve
-
00:02:13 our lectures videos. Okay. So PMS system in the POS system. What do we have? We have diseases,
-
00:02:24 drugs, login try, prescriptions treatments, users and user types. So so far, I think we
-
00:02:31 have only coded
-
00:02:36 Drugs and login and user and user types. So, let's run our application to verify that.
-
00:02:52 Okay, so we have registered for we have user types, we have log in and we have drugs. Okay,
-
00:03:07 first we are going to enable drugs C clean for only let's say medical doctors. And I
-
00:03:18 want it fully hit it, not only be visible, but not clickable so let's change its
-
00:03:28 Statues. How am I going to do that in the app in it?
-
00:03:37 I am going to set. Okay, this is not here so maybe here.
-
00:03:47 Okay, let's check our methods.
-
00:03:57 Okay, here we have top, login, top, register and BTN login. I'm going to write a method
-
00:04:07 here as
-
00:04:14 Set the Rocks panel.
-
00:04:21 And this panel will do this. Let me show you. So, where do we keep our loaded in statues?
-
00:04:38 Okay.
-
00:04:45 Logging operations Global metals.
-
00:04:51 Global methods.
-
00:04:54 No, not here.
-
00:04:58 In here. No, we have login. Try. No not this one.
-
00:05:09 Okay, let's look from our method. So we have log in. Try logging click.
-
00:05:18 Okay here. So this is inside login operations and logging operations is here. So I think
-
00:05:28 I'm will move these two. Here's
-
00:05:35 Global methods and
-
00:05:40 We have login. Try. No, no. This is a user generated class.
-
00:05:48 Yeah, okay. And
-
00:05:55 In the logging operations, we keep logged in user here.
-
00:06:02 So what am I going to do? Is I am going to set drugs pain on status with if login
-
00:06:16 Operations dots TBL or logged in user is not equal null, okay? Until I can do this with
-
00:06:24 a new check like this dots.
-
00:06:27 He and I should have used the type. Okay, so in user types, what do we have?
-
00:06:44 We have user type ID and user type name, right? So if it is not actually
-
00:06:54 Yeah, not equal to.
-
00:07:02 Medical doctors. Okay too.
-
00:07:06 Because this is already making. If I remember correctly.
-
00:07:12 User type is is here. Yes. You see, as you see, it is ID matching. So if it is not equal
-
00:07:20 to we will set
-
00:07:30 Main dots until we are top drugs. Visibility equal even
-
00:07:37 James.
-
00:07:41 Him.
-
00:07:46 Else.
-
00:07:50 We are going to set it as
-
00:07:52 wisdom.
-
00:07:55 And I also need to call this in two separate cases. Actually, three separate cases. Where
-
00:08:04 do I need to set it change? I need to set it change in the, in it up.
-
00:08:16 Yes.
-
00:08:17 Okay, so this is up in it CSI actually. This is also a custom cluster for. I will put it
-
00:08:29 here.
-
00:08:30 Okay, this is when we ask Global method starts.
-
00:08:33 Change set rocks panel.
-
00:08:37 Actually let's rename this to a better name like cetera, explain invisibility, yeah, now
-
00:08:42 it will ask me to rename wherever it is linked and it's only linked in here so far.
-
00:08:51 okay, it's ultimately named it as you seem and you are going to set it in log in operations,
-
00:08:58 login, try,
-
00:08:59 Actually change, login strategy, s, we can put it here.
-
00:09:12 Yeah, now we should work. Let's read try to see whether it is working or not.
-
00:09:28 So, we will call that method when the application first run to hide that window. Yes, it is
-
00:09:36 hidden. And now we will change it. Also login. So let's try as patient one.
-
00:09:45 Okay, patient on email. It's patient one at gmail.com, whatever our swords will be 1 and
-
00:09:57 user type. You'll be patients, register it and then, okay, we are not automatically logged
-
00:10:03 in, we should automatically login user after registration, okay? So we are going to
-
00:10:13 Call our logging operations, login, try logging operations and okay. It is inside custom closet.
-
00:10:25 So that said that using lecture 6 custom classes, you see lecture 6 is not changed. I mean,
-
00:10:34 the namespace. I could change that easily but I won't touch it right now.
-
00:10:39 All week, I can show you just need to control. F namespace lecture 6 or actually lecture
-
00:10:47 6 because we don't have anything else as that name to lecture 8. If I do that with entire
-
00:10:55 solution, everything will become lecture 8, simply however, it may break or application,
-
00:11:03 I'm not sure. We will see.
-
00:11:07 I hope that it's phones page.
-
00:11:10 Because I didn't take any backup.
-
00:11:16 So it says it is not accessible.
-
00:11:21 Intellisense should update it.
-
00:11:28 Okay, it says there is no
-
00:11:32 yeah, it is might have
-
00:11:38 Broken or something.
-
00:11:41 You may be actual, this is lecture nine. Why did we change it to lecture 6? Let's change
-
00:11:51 it to lecture 9.
-
00:11:54 And see what happens.
-
00:11:58 Okay, that could be.
-
00:12:05 Namespace name in here here.
-
00:12:08 Okay, everything looks for it.
-
00:12:12 Let's check the properties.
-
00:12:15 Okay, this lecture, 9 lecture 9.
-
00:12:19 Yeah, everything looks section 9.
-
00:12:23 Maybe check the properties. Here's
-
00:12:27 Okay, let your night, okay? Default namespace. I have to change that as well.
-
00:12:35 And then, let's see what happens.
-
00:12:42 Okay, so we have one and Lauren, okay? Other learners
-
00:12:52 Okay, so the problem is here you see Microsoft benefits targets and probably there is something
-
00:13:03 else.
-
00:13:05 C lectures.
-
00:13:10 That must be a reference to.
-
00:13:14 Move.
-
00:13:15 it says that lecture 8 like, oh I see
-
00:13:30 It says lion 200. Okay so we can't see lines image. So let's first enable that.
-
00:13:41 And it is in the text editor and in here, general of all languages. OK here words, ra
-
00:13:50 and line numbers and in the lines.
-
00:13:55 Okay, it does not here.
-
00:13:59 He just doesn't alternate auto-generated coach.
-
00:14:10 Okay, so we have a lecture naming problem and Vash where it is positional lecture 9
-
00:14:22 maybe window.
-
00:14:23 Everything looks correct.
-
00:14:26 Maybe we just need to reboot.
-
00:14:35 Can we have a problem solvers?
-
00:14:37 Because I've been a fixed targets. It is inside.
-
00:14:50 Yeah, this is not related to that.
-
00:14:57 Let's open the error.
-
00:15:02 Okay, it says this. So it's removed. So let's copy this errors.
-
00:15:11 and,
-
00:15:13 Correct. Route namespace stuck in the project file, so, it is related to somewhere here.
-
00:15:19 Probably.
-
00:15:20 Okay. In here, we have CG proche. Let's open it.
-
00:15:27 Yeah, here here, I have to change that to this. You see root namespace and then now
-
00:15:34 it should focus wrong.
-
00:15:39 Okay, so you see renaming the entire space.
-
00:15:47 Namespace is a bit problematic. Therefore it's it may cause with some trouble. Okay,
-
00:15:55 we were doing registration. And then automatic login, let's continue to death,
-
00:16:01 Here we have added lecture, 9 custom classes and now we will call our login operations
-
00:16:09 that login, try. You see login, try takes main window.
-
00:16:15 man and therefore I need something else here not normally this is reading the value is
-
00:16:25 that is coming from the extreme login email text and
-
00:16:31 Dan, the password of the text box, okay? So before I do that, I need to set main window
-
00:16:41 values as main Dot txt Login, email equal to
-
00:16:48 Okay, before I reset them.
-
00:16:54 Me and that you Exeter email.
-
00:16:58 Text.
-
00:17:01 And then I need to set password as well. So the password.
-
00:17:08 Here.
-
00:17:10 Jermaine that txt.
-
00:17:14 Login, password equal to this.
-
00:17:21 I can't say it like that but maybe this can work, I'm not sure. Yeah, then I will just
-
00:17:30 pass the maid here.
-
00:17:33 Okay. Now let's retry.
-
00:17:37 To register and see if it is automatically logged in or not.
-
00:17:45 By the way, this operation will be done. After the playing user user has been successfully
-
00:17:51 registered.
-
00:17:54 Okay. And here is Patient to Patient to Patient Gmail call, 110 and patients register. Okay.
-
00:18:08 You see until I click? OK. The application is not continuing. So this is the application
-
00:18:16 blocking event and when I click OK, it will continue. Okay, now we are you have successfully
-
00:18:23 logged it.
-
00:18:24 But we don't have any other C cream. Therefore, even though we are logged in we don't see
-
00:18:32 our trucks pain right now as we are supposed to. Also we didn't clear the text or other
-
00:18:41 things of the registers. Let's also clear them as
-
00:18:45 T main dots. Password tasty.
-
00:18:55 okay, pv1
-
00:18:59 Equal to nothing.
-
00:19:00 Or maybe there's clears. I don't know. Let's check it out. No, there is no clears. Okay,
-
00:19:08 let's change this to and
-
00:19:17 16 last night. Actually, you should also set an identifier to make them
-
00:19:28 Displaying as a registration. I what I mean is that me show you
-
00:19:40 So in here, I will rename them and I am hoping that it will automatically name everywhere,
-
00:19:46 txt first name, or let's say registers first name.
-
00:19:54 Okay, it is renamed here but I don't know if the references are renamed as well.
-
00:20:01 No, no, it didn't see name. So this didn't work.
-
00:20:14 So if I renamed here, Village tell me to rename any way, that would be a more appropriate
-
00:20:24 name. So I won't spend time with that right now. You can do that, however, it wouldn't
-
00:20:30 take too much signed by the way. Okay, so we are now able to register and when we register,
-
00:20:38 As a patient, we don't see the drug stop.
-
00:20:44 So, let's register with the doctors Authority.
-
00:20:48 Okay, so dr. Vaughn
-
00:20:54 Dr. Vaughn doctor on edge. She may not go 1-1 and talk to, you just stir. Okay, registered.
-
00:21:07 Okay. All fields are reset.
-
00:21:12 And now I can click drug stop. When I click refresh, it brings some drugs and that's at
-
00:21:21 the drug.
-
00:21:23 Suns 5.
-
00:21:25 Nine. So you see when I click somewhere else, it will tell me if there is anyone, but they
-
00:21:31 are not saved. Yet the save
-
00:21:42 Oh, I see, I shouldn't set truck ID because it is set as an identity if I see it correctly.
-
00:22:04 Therefore I need to disable editing of track ID in the window so that user cannot enter
-
00:22:13 or change the drug ID, okay? So let's see if it is the case.
-
00:22:19 Yes, it is identity. Therefore I have to disable edit of drug ID.
-
00:22:27 And how am I going to do that? I am going to do that simply with here. So the header
-
00:22:39 of the drug ID will be equal to Simply drug ID.
-
00:22:48 Okay.
-
00:22:49 and it will, I will set it as
-
00:22:57 edits change.
-
00:23:00 Okay, let's see. How do we do that?
-
00:23:12 sir style, perhaps
-
00:23:16 no.
-
00:23:17 Can use earlier the resize Clipper, content binding.
-
00:23:24 Other styles.
-
00:23:26 Okay. That is he's with only and I'm going to set it as true. So it will be only readable
-
00:23:35 but not editable. Let's try again.
-
00:23:51 Look, I will login as a doctor to let's see.
-
00:24:01 Users.
-
00:24:02 You have successfully logged in, I can log-in
-
00:24:13 parameters, we didn't reset them yet so they are here and drugs. Refresh. Okay, so you
-
00:24:21 see, I am not able to click or change or enter anything that I have to write it here, okay?
-
00:24:26 It's got us, 0, default value but I think it will be ignored.
-
00:24:35 it's
-
00:24:38 And then say, okay, now I'm going to save it and when I refresh you see are here as
-
00:24:46 expected and it is working great.
-
00:24:49 Okay, so now we can
-
00:24:55 Okay, after I log out. Let's see if this drug thing of disappeared.
-
00:25:01 Yes, it is disappeared but we are still on that window. So we need to change back to
-
00:25:08 login window.
-
00:25:10 Okay, let's go to our logout button.
-
00:25:16 It is here after that. Actually, I will just
-
00:25:21 Okay, set it here, man.
-
00:25:27 How can we do that? Yeah, I should do it here. Global Metals dots.
-
00:25:42 Bandits.
-
00:25:43 Okay, login.
-
00:25:45 Top login, select it true. And once the log user is logged out, we also need to check
-
00:26:06 some other things. I mean
-
00:26:14 in our application, currently usual can change values. If the even if they are looked at
-
00:26:22 because we are not doing a server-side or background check in are loaded in operations,
-
00:26:30 JV chassis last movie to custom classes as well. Okay. So in here, I need to make a check
-
00:26:44 I need to check first is user profile, log it in as a doctor.
-
00:26:51 so, what I need to do is simply
-
00:26:57 this okay, public static.
-
00:27:05 Bull is doctors.
-
00:27:09 No good in. Okay. What is this going to do it? It will just check this if it is user
-
00:27:23 type, not to return false.
-
00:27:26 Okay, actually I need to check if it is equal to 2.
-
00:27:34 If it is equal to 2 because that can be other user types as well, we just need to allow
-
00:27:43 for to. It would return true else it would return false
-
00:27:51 And I need to check that.
-
00:27:54 If is a doctor look in equal to false, it's from the hidden as it will be true. You see?
-
00:28:02 I am doing a method.
-
00:28:07 Using approach and never a duplicate code. You also need to follow this practice and
-
00:28:17 in are logged in operation. First, I need to check that if a doctor is you logged in
-
00:28:22 or not. So in global methods is a doctor locked in if it's equal false return. So I bought
-
00:28:31 a lot of none other than dr. User to
-
00:28:38 able to weave refresh or
-
00:28:46 Save changes. So I will not allow them to a direct page or save the name of data.
-
00:28:57 Okay, order delete data. Okay, so for each of these method, I am checking is a doctor
-
00:29:08 logoed in, okay?
-
00:29:13 So that's really try and see.
-
00:29:33 You can, let's login.
-
00:29:40 Okay, now I can click, I can refresh, I can change anything and I can say the flash on,
-
00:29:53 it's not safe. I need to click change the flash. Okay, so milligram okay you see. It
-
00:30:00 is showing an error displaying, why? Because we did set this as a small integers if I remember
-
00:30:08 correctly.
-
00:30:10 And small integer can be maximum 32k, so if I make it like this. Yes. Now working great.
-
00:30:19 And then I log out now, that's a green is gone. And if I log in as a different user,
-
00:30:26 we who is not a doctor, who is a patient
-
00:30:32 I won't have that.
-
00:30:34 Drugs, Pana drugs, paid on to see it and I can now go. Okay. Okay. Everything is working
-
00:30:47 as we want. However,
-
00:30:50 Assume that there are hundreds of thousands of trucks. What can we do in that case?
-
00:30:59 Okay, so in your project, I also want you to build your database
-
00:31:05 With synthetic data so that you can shop all of your futures first. Let's insert some synthetic
-
00:31:19 data into our database to do that.
-
00:31:24 Actually, I'm going to find a drug list.
-
00:31:29 Medical drug list. Txt some real data day database.
-
00:31:41 Okay, there are some
-
00:31:44 data. Here's submissions products. May be here. That's it.
-
00:31:50 okay, there is a product, no, but
-
00:32:02 That is no.
-
00:32:12 Marketing name for happiness, marketing students, know that. Let's see some missions. No.
-
00:32:25 What part of no.
-
00:32:30 Okay. There's another okay. There's farmer downloadable data.
-
00:32:38 I could also generate some random names and milligrams.
-
00:32:42 But let's have some real data because it is easy to find, I believe some part of more
-
00:32:52 logical form of logical names.
-
00:32:59 Okay, there is a c SV.
-
00:33:11 Data.
-
00:33:13 I think I can open this.
-
00:33:17 Most pets plus plus it would be faster.
-
00:33:26 So let's extract it
-
00:33:42 to here.
-
00:33:43 Anxiety is causing too much time.
-
00:33:46 Okay.
-
00:33:47 Okay, so that is somebody is milligram capsules.
-
00:33:52 Okay, for my kid. Okay. So maybe this is the name.
-
00:34:01 Yes, so you see they are ending with their milligrams. I think, but no, not all of them.
-
00:34:12 Okay, so that is the milligrams are hidden in here. Okay, so I need to parse this data
-
00:34:21 and add them to my database. Okay. There is also room for example capsule.
-
00:34:32 Stop imitating. Okay, so I think I can extract data from this one easily.
-
00:34:40 Yeah. Yeah, this looks nice. So, let's add some data to our database from this file,
-
00:34:53 How am I going to do that? If you wanders.
-
00:35:00 In my drugs panel, there are some columns automatically generated which I learnt once.
-
00:35:16 you see when you're working like this, you can accidentally generate
-
00:35:24 Let's add a bottle to here.
-
00:35:37 I will call it as Lord.
-
00:35:43 Data into a database.
-
00:35:51 Can we turn more data?
-
00:35:52 Okay.
-
00:35:53 It's a lot of data.
-
00:36:05 Let's compose The Click event.
-
00:36:11 Okay, it is ready.
-
00:36:16 Smile, as beta.
-
00:36:19 And it will tell me to compose a new method and
-
00:36:32 I will do it.
-
00:36:35 Here's its internal. Yeah, fine. And that is our data located, let's add this. So it
-
00:36:43 is 70 megabytes, right? Display the beak.
-
00:36:48 But if I add it to my project, it should be able to login to GitHub repository so it's
-
00:36:58 fine. Let's add that
-
00:37:00 data into another folder, as
-
00:37:05 Static data.
-
00:37:06 Here's and I will add an existing item.
-
00:37:14 On documents or files.
-
00:37:19 Here.
-
00:37:21 Okay, I need to copy this data to debug folders, otherwise it wouldn't work. So I'm going to
-
00:37:30 set it as copy if new verse
-
00:37:35 It's type willed action. Will be
-
00:37:40 Let's say that said it says non and let's Round Up station to see if it is copied as
-
00:37:46 expected or not.
-
00:37:52 That weird action makes whole lot of difference about how that will be treated.
-
00:38:01 And to be seen it here.
-
00:38:07 Type. No.
-
00:38:10 Okay, let's recheck.
-
00:38:13 Yes, it is not copy yet. Therefore, I need to change.
-
00:38:20 good action to not known, but
-
00:38:25 I think content? Yeah, no, let's start again.
-
00:38:36 Okay. Now I see, static data here, it's copy it. All right, actually, I didn't check this
-
00:38:49 folder was existing or not.
-
00:38:52 Oh, we also have some problem in Earth.
-
00:38:56 Yeah, I had I need to change this.
-
00:39:02 Pete. We made two column with previously. I don't remember.
-
00:39:12 19.
-
00:39:13 One moment I need to take a copy of this bottom first done.
-
00:39:23 I can control Z.
-
00:39:25 And as soon. Yeah, now it is working. So that wasn't an unnecessary, that wasn't unnecessary.
-
00:39:38 And then in drug stop, we are going to add our bottle at
-
00:39:49 Bother the police.
-
00:39:53 Okay. Okay, so we can know Court, what we are going to do is we're going to simply delete
-
00:40:06 values in this CSV file. So it will be under static data for each. I need to add using
-
00:40:20 System. Iowa.
-
00:40:22 Put output operations.
-
00:40:26 Here and we would read wild R38 lines. You don't need to read all of them at one star
-
00:40:40 far.
-
00:40:41 You should Bond and we are lying. Okay, so what is the formats? One, two, three.
-
00:40:50 Four five.
-
00:40:52 Seven, eight, nine, ten. Okay. The tenth item is the drug name and that's all I need. So
-
00:41:08 equal to VR line that split
-
00:41:15 and,
-
00:41:16 The tenth item and then I am going to get its milligram. How am I going to do that?
-
00:41:26 I am going to split it.
-
00:41:32 In two parts.
-
00:41:35 And I think, I think I just need extract.
-
00:41:41 Double values inside it. Yeah.
-
00:41:46 so,
-
00:41:48 yeah, I think we can do it like this, so,
-
00:41:57 Echoes, we are line that's late.
-
00:42:03 North Carolina, drug name and Porsche.
-
00:42:10 Midnight starts count or length.
-
00:42:16 and if
-
00:42:25 Contains.
-
00:42:33 or equal to your let's say equal to
-
00:42:36 If it is equal to milligram, then I have the milligram as a previous value. So in here
-
00:42:47 I'm going to get generate an instance of TV and Rock.
-
00:42:54 Here drug, something like this.
-
00:42:59 If you are drug and TV, attractor that those milligram so are those is pet, s, small, integer
-
00:43:14 Darfur.
-
00:43:15 If it is not an integers, I would have a problem. Therefore I think I will make it like this.
-
00:43:26 Equal to convert inch 32. Okay, set this walls.
-
00:43:37 And I minus one.
-
00:43:50 Expecting short Darfur to in 13 and 16 and then Bridge.
-
00:43:58 And the drug name will be.
-
00:44:04 Set here.
-
00:44:06 Okay.
-
00:44:09 Okay, so for firstly insert, I will insert data for each 100 items. So for to be able
-
00:44:29 to do that, I will add a counter like this.
-
00:44:36 It will start from one and it will get increased by one. And I'm going to also add a using
-
00:44:46 PMX
-
00:44:47 PMS context, my context equal to me.
-
00:44:52 Context. Okay.
-
00:44:53 and what we are going to do is
-
00:45:07 you are going to edit or contest. But how if my drug
-
00:45:16 That those milligram not equal to 0, okay?
-
00:45:23 Then my context are TV and drugs thoughts at. So it will say it says, begins tracking,
-
00:45:32 the given entity and any others reachable entities that are not already being tracked,
-
00:45:39 okay?
-
00:45:40 So, I'm just simply at my drug.
-
00:45:46 Okay. And pour 100 each item.
-
00:45:56 okay, so if our country is equal to or less 8%,
-
00:46:05 Like this.
-
00:46:07 I will just
-
00:46:10 call Save changes. However, this would currently this bolt, three is my application interface
-
00:46:22 because we are not using any multi-threading. We are blocking the main threat and therefore
-
00:46:29 until this operation is completed, our screen will be frozen.
-
00:46:37 And let's see what happens.
-
00:46:41 so, let's log in as a doctor,
-
00:46:47 Okay, here, and let's start loading. Okay, we have a problem. Yeah, we have forgotten
-
00:47:04 to add static data folder name.
-
00:47:09 It should be like this.
-
00:47:14 Yeah, all my moments. I made mistake.
-
00:47:21 Okay. This is like make it like, yeah.
-
00:47:39 I think the opposite would work as well.
-
00:47:44 Okay.
-
00:47:47 okay, so there are some
-
00:47:52 Inputs, that doesn't match but it looks correct. Why?
-
00:47:59 Okay, it was not able to convert this into an integer.
-
00:48:08 so, I think what I'm going to do is
-
00:48:12 Simply like this in 36 try parts. So that won't happen. Any errors. Yeah. This is the
-
00:48:25 old and this is the split. Okay, so if it remains as 0,
-
00:48:35 Okay, why not working?
-
00:48:48 A property or index of may not be pastors, enough ref parameter F. So, therefore,
-
00:49:05 what I'm going to do is if
-
00:49:14 k equal to
-
00:49:28 If it is person successfully it done, it will be assigned to those milligram.
-
00:49:37 So you see, ours small end is not.
-
00:49:43 Precise. Yeah, I think what we need to do is we need to change our database.
-
00:49:50 so, we need to change this from small integer to
-
00:50:02 I think they came, yes, they came out but with Precision to
-
00:50:08 so,
-
00:50:11 Yeah, I think this is going to be a better. We can save them as double as well but taken
-
00:50:26 Precision, to should be better.
-
00:50:37 You can position to.
-
00:50:45 Yeah, I think I will make this as let's make this as 12. I don't think shadow of such really
-
00:50:58 grow and maybe we can make it even tongue. Yeah.
-
00:51:03 The save it. And after we make say,
-
00:51:08 okay, we need to change our references as well, so
-
00:51:15 Let's reverse engineered and okay. So it will cause us some
-
00:51:25 other tight changes as well. So the we could have
-
00:51:34 Okay, not, this is not the correct database. It is from my other leg pictures. Okay. I
-
00:51:43 need to add a new database.
-
00:51:52 So, that's first moment.
-
00:51:57 Get the server name.
-
00:52:01 Okay, the it will be PMS, okay.
-
00:52:11 Okay, everything is here.
-
00:52:18 Okay.
-
00:52:20 Okay, this will be refreshed. Yes.
-
00:52:26 so, now drug milligram will be a type of
-
00:52:31 Let's see, where is this?
-
00:52:34 Let's go to the class.
-
00:52:49 It's been the type of day, C'Mon, yes. And you see they cover?
-
00:52:55 Okay, so we are going to change or try Parts into the cabin.
-
00:53:03 In this, make it nasty. Sits try.
-
00:53:09 It's a vindictive all tryparse and he sits right. Yes. Now it should work. Let's delete
-
00:53:19 the older data.
-
00:53:22 and,
-
00:53:24 Okay, let's try what happens.
-
00:53:36 now, we should be able to hold milligrams correctly supposed to be
-
00:54:02 The fish that is nothing less Lord and let's see. Okay. They are getting loaded as you
-
00:54:11 can see I'm pretty fast.
-
00:54:15 you see, there are also
-
00:54:20 Duplicate values as you can see.
-
00:54:24 And I think we can prevent that.
-
00:54:29 However,
-
00:54:30 how could be prevented?
-
00:54:42 If I add a unique index, I wonder if that would cause an airbrush.
-
00:54:50 Yeah, probably that much.
-
00:54:55 I don't know if Entity framework puts handle that or not.
-
00:55:04 You see so many duplicate trucks, they are duplicate.
-
00:55:09 Okay. It is working but we are adding duplicate values. So we want to prevent duplicate Edition
-
00:55:20 and to be able to do that, we can add a unique index. Okay, let's open. An instance of SQL
-
00:55:29 Server management.
-
00:55:32 If you are not able to add a new index, just open the live instance, I don't know, sometimes
-
00:55:38 it is getting packed or something.
-
00:55:50 One clustered index.
-
00:55:59 Okay, what we're going to do is we are going to add rough name and Drug dose. Okay? So
-
00:56:13 let's change the orders. The order is important, why? Because if you the, the more identifying
-
00:56:27 column should come fat first, so the milligram is not the most identifying one in here.
-
00:56:34 The most identifying thing is the name than the milligram and this will be unique, okay?
-
00:56:41 So when I set it unique, it will throw me an error right now because there are duplicate
-
00:56:45 values. Just you see let me show you see index faded because there are two picket values
-
00:56:53 and to prevent it, I I need to delete existing values.
-
00:57:01 Okay, and now it will be successful. However, now when I try to add with the usual method,
-
00:57:13 I think I will get errors.
-
00:57:17 I'm not sure if Entity framework will handle that or not.
-
00:57:24 So, let's see.
-
00:57:28 Oh, let's refresh our table, maybe it will.
-
00:57:41 Also take into consideration that index. I'm not sure.
-
00:57:45 Okay, let's make this comment out.
-
00:57:54 And let's go to TBI drugs.
-
00:58:02 Okay. There is index and it is unique. Yeah. Maybe it will consider this as well. I'm not
-
00:58:14 sure. But see, you see? It has indexed name of drug name. Name of tools milligram.
-
00:58:22 If it's handles, this can say it is also it will make our job, much easier, it will just
-
00:58:30 sort out duplicate values.
-
00:58:35 And less loads. I hope. No other. Okay, you got an address so you see we got either exception.
-
00:58:49 I wonder if there is an easier way.
-
00:58:55 okay, that's see if there is any
-
00:59:07 he is a very
-
00:59:10 Okay, there is a door updates.
-
00:59:25 and it says, add or update here, maybe that was for
-
00:59:32 Let's try that.
-
00:59:38 I think it may be requiring another reference, let's see.
-
01:00:20 it is requiring this until migrations, then I edit
-
01:00:25 Okay. It goes off and framework or we are using this. So,
-
01:01:01 It is update entity.
-
01:01:02 And there's ass or update.
-
01:01:25 Let's see if update works on marks.
-
01:01:34 Yeah, there is update. Okay, begins tracking the given unto the. An answer is reachable
-
01:01:41 from the given entity using and state modified set by default but see below for kids watching.
-
01:01:49 Of course.
-
01:01:56 Let's see, I'm not sure if this will work or not, so I will just delete the existing
-
01:02:01 drugs.
-
01:02:04 And me, try.
-
01:02:18 Okay, let's just run.
-
01:02:45 Okay.
-
01:02:52 Okay, so
-
01:03:06 Updated in Fork.
-
01:03:15 Yeah, put up all the hours Mass insert will not work if you follow this path.
-
01:03:58 What we can do is alternatively for each item.
-
01:04:06 Instead of the counter we can save changes at each row.
-
01:04:13 so,
-
01:04:15 Dutch Schultz.
-
01:04:18 Remove our problem. Because after each row, save, it will just check the database.
-
01:04:29 I believe. I'm not sure, let's right.
-
01:04:34 So if it exists, it will update, if it's not, it will insert, but this will be probably
-
01:04:40 slower. I am sure that can be a way to make it faster. Like we can keep the local cage
-
01:04:47 of all drugs and then load them later.
-
01:04:56 Oh, I see update is not working because it is also checking primary ID.
-
01:05:09 Yeah.
-
01:05:13 Because their primary ID is different.
-
01:05:23 It didn't work. So what else we need to do.
-
01:09:14 It looks like that is no easier way.
-
01:09:18 So, we need to check that whether it exists or not.
-
01:09:31 Okay. Find users primary K. Therefore, I need to look for so select. Yeah.
-
01:09:46 There are dots.
-
01:09:56 equal to,
-
01:10:00 Okay, if there's nobody saw something.
-
01:10:27 Okay. Now, this will become bull.
-
01:10:52 Why?
-
01:11:03 okay, so if this is empty,
-
01:11:17 no, we will add and then
-
01:11:26 Okay, with this approach. I think
-
01:11:34 it should work on mushroom now.
-
01:11:39 Let's try.
-
01:11:46 So this should also use the local cage as well.
-
01:11:51 However, each time, it will make a database query to if it is not in the local cage.
-
01:11:59 I don't know how our form, how much performance it will have.
-
01:12:09 well, I guess I ain't trusting
-
01:12:26 This is interesting. Why?
-
01:12:43 I think we need to use bad. Not select. Yes, I know he isn't.
-
01:12:47 Thus and now it will return a drug. And if it is not new here,
-
01:12:55 Now, it should work. Fine. We're and select make difference in anticipating working here.
-
01:13:04 Why do we still get ever?
-
01:13:25 I know.
-
01:13:39 Because this is not checking the local cage. Probably.
-
01:13:53 I think I also need to check local. And and then if
-
01:13:58 Yeah, I'm going to make another check here, so this time, I will check local.
-
01:14:06 I'm not sure if this will work or not. Nice. Try
-
01:14:14 First, we will check database. Then we will check the local.
-
01:14:21 Actually I can handle local myself to yeah. It would be even faster if there's if this
-
01:14:29 doesn't work, I will do that.
-
01:14:47 It looks like working. Let's see how many drugs we have. Is it so far?
-
01:14:53 Okay, you see now we are adding much slower, but each one is unique. As you see we are
-
01:15:00 even able to add lavash milligrams like this.
-
01:15:06 Okay. We are adding so much Rock Spot. You see our interface is completely Frozen and
-
01:15:16 I'm going to show you how we can fix it. You see this is frozen. This is frozen everywhere
-
01:15:21 is frozen because currently This Thread is running under the main threat under the main
-
01:15:28 window threat. Therefore, it is blocking the entire thread until it is completed. Therefore
-
01:15:36 my
-
01:15:37 User interface is completely Frozen. Okay, so now I will show you that.
-
01:15:48 okay, so we are going to
-
01:15:51 We are going to use a task Factory to start as a new task and update our interface. We
-
01:16:03 have done that before but it will be good to remember again. Okay. So let's open that
-
01:16:15 top.
-
01:16:16 And that's either of you already have a label, so we can use that. And okay, here.
-
01:16:26 Yeah, I think I can encapsulate within a task like task that factory start new. Okay, it
-
01:16:42 will be so
-
01:16:47 Task.
-
01:16:49 Okay, so here are parentheses begin.
-
01:16:53 Here it hands, or we already, we need to move this to here. Okay. So this is south and populating
-
01:17:03 the task and
-
01:17:06 now, to be able to update our label, we also need to
-
01:17:20 Change how this work as weeds.
-
01:17:25 Like this.
-
01:17:26 Jay here, I need his
-
01:17:34 Okay, what do I need?
-
01:17:42 We need.
-
01:17:45 Okay.
-
01:17:47 Dispatchers. Begin invoke. Yeah, I am remember it's and me need a delegate.
-
01:18:02 I can't remember the exact
-
01:18:04 Chase.
-
01:18:11 I can't remember the exact sign text so I'm going to check it.
-
01:18:17 QB can inbox at delegate, I'm going to put
-
01:18:23 So, what is the Exile have examples?
-
01:18:44 Okay.
-
01:18:49 Oh, never action. Delegates here.
-
01:19:07 So this is the formula. I mean, assigned text.
-
01:19:14 You action.
-
01:19:18 and inside, here's
-
01:19:19 What do we have? We have delegates.
-
01:19:34 It was like this.
-
01:19:38 Give him the boot.
-
01:19:52 So action is self encapsulated like this.
-
01:19:58 and then actually, it is telling that this is an action and then
-
01:20:07 Tis.
-
01:20:08 Like this. Yes. Now I understand. So this is simply same as dispatcher, but here we
-
01:20:23 are putting this to exclusively. Tell the compiler that this is an action.
-
01:20:32 And it will just put this inside here. Okay, so now this will support multi-threading as
-
01:20:38 well to threats as well and in our task Factory, what we are going to do is we are going to
-
01:20:50 update the label
-
01:20:54 I think we can update the label as its
-
01:20:58 102 changes so far inserted.
-
01:21:07 The Rock's count, perhaps.
-
01:21:16 I will make it like this soil. We won't get increase of the counter. If you are not adding
-
01:21:23 it and this continued with continue this Loop. Yes. Okay. And let's add.
-
01:21:34 Okay, now, let's see.
-
01:21:42 Let's delete all the existing drugs.
-
01:21:44 Although we increase the counter somewhere.
-
01:21:49 Or I have to increase it actually use.
-
01:21:55 Not Ash, that's stop.
-
01:21:59 It must make it like this.
-
01:22:22 Okay, that's login with users.
-
01:22:37 And let's go to the rocks and fish, there is nothing that's load. You see interface
-
01:22:45 didn't freeze and you see how fast we are inserting into database.
-
01:22:53 and when we select,
-
01:22:57 Called Soft room, TBL rocks. Let's see. Oh, this counter. And this is not matching as
-
01:23:06 you can see. So we have an error somewhere.
-
01:23:11 Where do we have a North?
-
01:23:17 Simply okay. We have counters.
-
01:23:21 We only count.
-
01:23:25 Oh, I know. So if this is not null, we also need to continue. I see
-
01:23:37 I think I can fix this. So this is too much increasing how to fix is simply
-
01:23:45 let's find a bowl here.
-
01:23:52 False and evil said it true here.
-
01:23:57 and then,
-
01:23:58 okay, if
-
01:24:01 JBL edit and continue now, it should work batters. Okay, let's restart the application.
-
01:24:15 Okay.
-
01:24:18 Okay, let's login.
-
01:24:28 And let's start loading. Okay, so you see it is now much slower and probably totally
-
01:24:51 correct.
-
01:24:52 okay, as you can see,
-
01:24:56 Yes. Okay you see, there is a one difference because we have started the counter from 1
-
01:25:07 instead of 0. And this is how we are adding the database. This can be speed up with tuning
-
01:25:17 such as we also keep all drugs in the memory and we do a faster check rather than see cooled
-
01:25:25 checking.
-
01:25:27 And but it should for ready fast as well right now. Okay, so
-
01:25:34 I am going to stop the application now. We have so many drugs, okay. And when we lord,
-
01:25:45 we were limiting it to 100 as here. Because if we take 100,000 drugs, into the screen,
-
01:25:54 that would make our application unusable. So, when I lost refresh, you see, there are
-
01:26:02 so many drugs like this.
-
01:26:04 And yeah we can make it like this. We see their ideas, visit their milligram Doses and
-
01:26:16 yeah. However let's say I want to see drugs that have overs
-
01:26:23 Ten milligram dose. How can I do that? I need to add sorting and filtering. Okay, so how
-
01:26:34 am I going to do it? Meanwhile, I am doing it. I will load more data into the database.
-
01:26:43 Okay. So how am I going to do that? I will just delete this copy and paste this so I
-
01:26:55 can work.
-
01:26:58 and,
-
01:26:59 You see in your project, I am expecting same from you, you should have a lot of data in
-
01:27:04 your database to display your application, okay? Not just fear of data.
-
01:27:10 You can generate synthetic data or find a data from internet. Whatever it is fine.
-
01:27:19 Okay, let's close this. Okay, currently, of course, it is causing a Sloane's in my computer,
-
01:27:29 but it is fine. So we need to add filtering options. Let's start adding them first. We
-
01:27:38 should add some sorting such as sort by, let's say, sort by milligram or sort by name we
-
01:27:49 can do each of them.
-
01:27:52 So, let's edit to sorting options, okay? So we will support both of them.
-
01:27:59 To do that. We are going to add combo box and I will do it with, let's say values and
-
01:28:10 Naming. I mean I will bind it to a class list. I will show you. So let's make this like this
-
01:28:23 and make it's like this, okay.
-
01:28:27 So, I will add it into the in it.
-
01:28:33 And I think we can define a concierge or let's define that claw. Okay, we it's fine to Define
-
01:28:43 it here as well public class.
-
01:28:48 Sorting options.
-
01:28:49 Okay, and what it is going to have. It will have property integer or
-
01:28:57 Yeah, let's do it like that.
-
01:29:02 Okay, maybe we should make it as. Yeah. I will put a new instead of that illumination
-
01:29:10 and which sorting I will name it like that. So it will have sort by drug name. Ask ending.
-
01:29:24 Sort by Rock named standing and sort by.
-
01:29:35 Okay. Milligram or those rock, those are scanning sort by drag those standing. We can also add
-
01:29:50 the salting with ID Swords by ID scanning sort by Rock ID is Channing okay
-
01:29:59 Okay, and then it will have another value. So this is, this doesn't have to be inside
-
01:30:09 it, but let's keep it inside it. Here, it should work. It is going to have to property.
-
01:30:15 First one will be, which sorting is which
-
01:30:21 Option.
-
01:30:23 Or sort option.
-
01:30:27 And then it will have another property.
-
01:30:29 Okay, sit in consonance with the property. Yeah, this has to be public as well, so that
-
01:30:36 it can be public and then public string.
-
01:30:42 Hazard and home name, okay?
-
01:30:50 If we can't, can we give a name for this? Let's see. C. Sharp
-
01:30:58 I know Molly's custom names. I don't know if it is possible. What?
-
01:31:08 Here. Can
-
01:31:10 Okay, so we can try this play. Yes, it's a good idea. So here,
-
01:31:21 let's see why it is not working. Okay? Be at annotations.
-
01:31:27 okay, since we can set a numeration as well, I think you don't even need this class, and
-
01:31:37 this play will be poured by
-
01:31:40 Okay. Why do we have a problem with this?
-
01:31:52 Yeah, I need name equal to, which is sort by am drunk name. Questioning
-
01:32:03 Okay, so I'm going to be machine. Yeah, now let's set any relations to other ones.
-
01:32:13 Sanding.
-
01:32:15 And sort by the rock. Those are standing.
-
01:32:20 Okay, good luck. Those is chanting this enumerate. These annotations are extremely useful. You
-
01:32:29 can use it for simply anything.
-
01:32:32 And Rocco's The Shining and rock ID.
-
01:32:37 idea, scanning and
-
01:32:43 The Rock.
-
01:32:45 I need this channel. This video display name, okay? And we are adding rocks, but they are
-
01:32:59 getting Snowbird, what you are unoptimized queries. So we need to optimize our query.
-
01:33:09 Okay?
-
01:33:10 all right, and
-
01:33:13 Okay, so it
-
01:33:30 has become too slow of this who are both cage creating and database creating. I believe
-
01:33:38 we may be at the end of our drum memory. Yeah, pretty much.
-
01:33:44 Okay. Okay. I could do a lot of optimization and provide it to be like this, but that is
-
01:33:59 not our topic at the moment. Maybe I can do it at the end of the lecture so I will just
-
01:34:05 let it be like this.
-
01:34:08 We could have also an error thrown, so it's not working anymore, but I'm not sure.
-
01:34:15 Okay, let's continue. So what we are going to do is we are going to have a list of enumeration
-
01:34:26 and bind it to our combo box, okay? So how are we going to do that? This is okay, so
-
01:34:36 this first combo box will be okay. Actually. We should, I will just sort it with a single
-
01:34:43 option so you could also do it with me.
-
01:34:46 Options as well, but it is not necessary to show right now. Combo box. Okay, CMB sorting
-
01:34:55 Rocks. Okay, so this will have
-
01:35:02 okay, something like this in our application in it.
-
01:35:10 Means CMB shorting, drugs itemssource will be equal to NIV list.
-
01:35:21 I think, okay.
-
01:35:27 Okay, so have this.
-
01:35:34 Relations. So in here, we will have them like this.
-
01:35:45 Or yeah, let me check something.
-
01:36:00 Let's see if this is possible.
-
01:36:08 Okay, so it is possible like this, okay? And I'm getting values type of which sporting,
-
01:36:26 let's see, how will it be displayed?
-
01:36:31 Okay dance. Let's close this.
-
01:36:37 We have enough number of items, it's fine. So probably an error happens and since it
-
01:36:46 was running in the stress mode, we didn't see it.
-
01:36:54 Okay, so
-
01:36:59 here's,
-
01:37:02 Let's refresh and this is, okay, so currently it is displaying the value. However, I need
-
01:37:10 to display their display name.
-
01:37:14 And how can I set it?
-
01:37:17 okay, let's play the name of heirlooms in combobox, see
-
01:37:30 Someone has already asked that.
-
01:37:34 Volume volume description. Yeah, maybe something like this.
-
01:37:46 let's see, what will this generate but
-
01:37:55 this will be volume members.
-
01:38:02 It is no money of members.
-
01:38:30 Okay.
-
01:38:37 Time converters.
-
01:38:51 Dan.
-
01:38:58 Let's ask it in another way.
-
01:39:26 Wow, I see.
-
01:39:38 This looks like that.
-
01:39:54 Correct way. But let's see. So this data, source and item source
-
01:40:28 What does no display member why? Okay there is this flame Amber path.
-
01:40:36 What happens if I make it as a name?
-
01:40:41 Because it is the name.
-
01:40:47 My hobby is rocks while I'm not sure if we will see.
-
01:41:07 Or nothing.
-
01:41:14 Someone has already asked.
-
01:41:30 Yeah, maybe I need to set the description and implementation. I see.
-
01:41:42 A lot of extra cords.
-
01:42:03 So, that is yet.
-
01:42:23 It's returns to Warrior the set.
-
01:42:31 Okay, on property. Change it?
-
01:43:02 I'm done.
-
01:43:21 Okay, this is what we have and done.
-
01:43:47 There is. I class homework.
-
01:44:12 Example.
-
01:44:17 Okay.
-
01:44:22 So there is an animal helper class.
-
01:44:31 and,
-
01:44:34 Oh, it is also converters.
-
01:44:52 kind of,
-
01:45:17 Is it looks better, I think.
-
01:45:44 It is the model and select tutorial search. Type item shows energy source types. Yeah,
-
01:45:58 this one.
-
01:46:00 Okay, let's try this implementing.
-
01:46:05 So, here's
-
01:46:08 Static innumerable, get penalty.
-
01:46:12 So, get movies objects.
-
01:46:16 I need to use this.
-
01:46:22 Maybe like this.
-
01:46:25 And it is supposed to take this.
-
01:46:37 Type of tea.
-
01:46:52 Get a room searched. I see why it is not working.
-
01:47:07 Maybe to least perhaps.
-
01:47:24 No.
-
01:47:28 Yeah, looks like in the converters.
-
01:48:00 Or we can have a temporary class to hold data of. Hello.
-
01:48:35 such as
-
01:48:37 I think that would be a simple solution.
-
01:48:45 But that defeats the purpose of using any Malaysian. Okay, let's see why there is no
-
01:48:55 cast effects time. I don't understand why there is no easy.
-
01:49:11 So much so much quotes.
-
01:49:34 Yeah, I think.
-
01:49:39 Instead of this.
-
01:49:56 I'm looking if there's an easier solution, but that doesn't seem to be.
-
01:50:05 Can we Define a conversion of this?
-
01:50:38 No, there's no conversation something like that.
-
01:51:12 Yeah, let's make it a different way. So let's add a public class. I will go with the easy
-
01:51:31 solution and sorting options. I will name it as
-
01:51:41 Here's it will have something option. By the way, it will have an enumeration.
-
01:51:47 Like this, which sort?
-
01:51:53 We can name it fast then it will have a public stink as Pop sting description.
-
01:52:11 I will make it automated. Let me show you. So here we are going to have a list of reporting
-
01:52:25 option.
-
01:52:28 Options privates void in, its sorting options and inside here.
-
01:52:36 We are going to get any medication, okay?
-
01:52:46 Okay, how do they animated?
-
01:52:56 Like this? Yeah.
-
01:53:02 So you also need please.
-
01:53:12 Anna Maria.
-
01:53:16 Okay, for this. We need reflection.
-
01:53:28 Component model.
-
01:53:35 Yeah, so here we will use description instead of name.
-
01:53:41 Just to not that easy, but easier to understand.
-
01:53:47 And here you are going to have a for each first.
-
01:53:55 is newbie from static or
-
01:54:00 five, static doesn't matter.
-
01:54:09 we will initialize it, it
-
01:54:22 Nice this. Then we will this
-
01:54:26 Okay, type of car soft.
-
01:54:35 And here's what you're going to do is we will add new elements to our list. Need sorting
-
01:54:45 option, item.
-
01:54:46 Okay, here's field. Have descriptions of the description will be string value.
-
01:54:54 both short and
-
01:54:56 Which source will be equal to.
-
01:55:03 I think just sort it should look like this.
-
01:55:09 okay, and we need to call this on our
-
01:55:13 In it. Application, here is
-
01:55:18 We will set items or sequel to our list.
-
01:55:28 here's,
-
01:55:30 And the display member path will be equal to as our description, okay? Like this.
-
01:55:40 I think other Solutions were harder to understand. So we just added a one helper method like
-
01:55:48 this. And
-
01:55:55 Metal like this to initialize our list automatically from Malaysian, okay?
-
01:56:09 Oh, it's still not working. Why
-
01:56:17 We just set the display remember PAD as a description.
-
01:56:21 Maybe I'm not working. That's rest. Hard to see.
-
01:56:34 Yeah. Yeah, our methods has a problem.
-
01:56:48 So here we have a problem. It is looking for description attribute. We already have description.
-
01:56:55 So what is not working?
-
01:56:58 Oh, I see not this flavor, test conniption.
-
01:57:06 So it has to be like this.
-
01:57:10 Yeah, let's make it like that.
-
01:57:17 Okay.
-
01:57:22 Description equal or you're not working on t.
-
01:57:27 Okay, let's see. Yes. Now, working. So we will replace this
-
01:57:41 This.
-
01:57:43 We're not going to think.
-
01:57:54 Interesting watching.
-
01:57:58 Let's money on the fix it.
-
01:58:05 What I start?
-
01:58:07 I would except expect that I would, it would be easy to just bind it to description, but
-
01:58:16 it appears that there is no easier way.
-
01:58:20 So, we had to have some extra recording.
-
01:58:25 And now working. Okay, so now it's time to coat our sorting things.
-
01:58:34 Are we going to do it? We are going to do it in a logging operations and in here. So
-
01:58:44 you see we are going to have, we are going to call this method. But this time we will
-
01:58:56 take into our
-
01:58:59 Sorting. Okay, so we are going to have a switch and this switch will take Global dots.
-
01:59:17 Global method. Maine.
-
01:59:21 Combo box users sorting drugs. Okay, maybe it will also generate
-
01:59:32 That's just nice. Try to generate it with switch autocomplete, no pork. Okay, so which
-
01:59:45 cases we have here?
-
01:59:48 Actually, I need to use.
-
01:59:53 Selected item. And
-
01:59:57 Now, it should work automatically. Yeah.
-
02:00:03 Let's try selecteditem darts.
-
02:00:08 no selected item, and I have to convert it to
-
02:00:18 14.
-
02:00:20 That was our animation name.
-
02:00:29 That's named as I can't change them.
-
02:00:32 Okay, let's make you bitch. You can see
-
02:00:41 Here like this.
-
02:00:50 Okay, to be able to use it, I am going to add using static lecture app in it, so here's
-
02:00:59 now that I can use it and now it should automatically generate I think switch.
-
02:01:07 Okay, they are automatically filled as you see. And now
-
02:01:14 Base it on the selected option, I will use it. So this is a default option, a scanning
-
02:01:24 orders, you see. Now, let's sort this Channing. Okay. This channeling here and let's sort
-
02:01:34 by name. So it will simply take name, ask anding? And then we are going to
-
02:01:46 Sort by descending.
-
02:01:47 And then, let's sort by those.
-
02:01:57 You see, it is being harder. When you use Entity framework, I could make this much easier
-
02:02:03 with traditional.
-
02:02:09 Database functions methods, but it also has downsides. Dissolves has downsides. So you
-
02:02:17 have to decide. Okay. So we also need something else for this work. What do we need?
-
02:02:26 When combo box is changed, we need to call our refresh method so it will be automatically
-
02:02:35 getting refresh it. So let's go to here. And here we are going to add an event here. So
-
02:02:44 let's say selection changes.
-
02:02:46 Where is it?
-
02:02:49 Here I double-click the event is simply generated and it will just simply call this method.
-
02:03:00 You see how it is good to write methods, instead of copy pasting code, it just reduces your
-
02:03:09 Cold, reduces the Need You. Denis love riding More chords.
-
02:03:17 Okay, let's login.
-
02:03:24 Let's refresh. Do we have a problem or? Okay. So we also need something. If there is nothing
-
02:03:37 selected it would cause error. Therefore, we are going to edit application with a selected
-
02:03:44 option. So 0 1, 2 3 4, the 4 is our default. Therefore we are going to set selected index
-
02:03:56 equal to 4, okay?
-
02:03:58 This will be this part selected index, it is, it will be same as the previous working.
-
02:04:11 Say it will be by default sort by idea, scanning, okay.
-
02:04:22 You see sort my eyes scanning refresh.
-
02:04:25 Okay, we have selected unable to cast object type sorting option.
-
02:04:32 Why why?
-
02:04:33 Yeah, there's which sort of oh I see I need to get this.
-
02:04:45 However, I am not able to get interesting selected item.
-
02:04:56 So, this is object.
-
02:05:02 oh, I know, the reason I know the reason first, I need to type this into
-
02:05:13 All are.
-
02:05:16 Glass here's which is sorting option.
-
02:05:21 and then I need to get
-
02:05:24 Okay, I need to add another parentheses here.
-
02:05:32 And then I need to get which source. Okay, now it will work so we will cast it first.
-
02:05:40 The type of the class that this list is holding which lists the lists be bound as an item
-
02:05:48 Source or combo box, okay? Because that list contains type of objects type of sorting option,
-
02:05:57 object objects.
-
02:05:58 Okay, let's login.
-
02:05:59 And refresh. Okay, they are working and sorted by I ID. Let's change sorting to drag name,
-
02:06:13 okay? You see Rock named is standing order and it is starting from the letter Z, let's
-
02:06:20 sort by those. Okay? You see there are up to eight thousand forty, four hundred milligrams
-
02:06:30 those and it is milk thistle.
-
02:06:34 Iraq. I think this is supplementarity think if I remember correctly and there is cover.
-
02:06:40 Ginger garlic. Yeah. Garlic is also the garlic Villeneuve.
-
02:06:45 Okay, so maybe you can oh this also sore spot, this is locally sorting. This is not sorting
-
02:06:54 the entire database. This is sorting within the results, for example, if I make it a scanning
-
02:07:01 I think here's you see it is going as low as zero point zero 2 milligram. It is a tinted
-
02:07:15 asteroid. So this is probably a really dangerous drug and let's see it. What is
-
02:07:28 it is
-
02:07:29 Okay, yeah, it's done. Hormone-related luck anyway. And so, yes, it is working great as
-
02:07:36 expected. We can sort them automatically within their displayed results. I will also show
-
02:07:44 searching filtering in the next week. So I think this is enough for this week. Let's
-
02:07:50 take our notes. Okay, let's open.
-
02:07:57 Okay, here's here.
-
02:08:01 Did you take a nap next weekend? Okay, yeah we did that. Nice, that's open lecture 9.
-
02:08:12 Context. Okay, so in lecture 9, what have we done?
-
02:08:21 Okay. How to hide and display tab. According
-
02:08:29 So, the authority of the log of a users.
-
02:08:47 Okay, how to?
-
02:08:49 Okay, lat an idiot CSV data set into the database feet and step very work.
-
02:09:01 Okay, how to utilize task Factory to prevent okay? Usually in terms of pace, please
-
02:09:27 How to?
-
02:09:28 Update label won't stop. That's
-
02:09:33 some tasks with.
-
02:09:35 Begin in Vogue or dispatcher? Yes.
-
02:09:41 Dispatches.
-
02:09:42 Okay, what us we have displayed oh how to add unique, this constraint to a database
-
02:09:58 table, which defining a unique index, okay?
-
02:10:06 and,
-
02:10:08 I'm sure unique adding to the database when using non-stick framework.
-
02:10:17 Okay, how to achieve the end? Let's say.
-
02:10:26 Let's say how to achieve.
-
02:10:29 How to add sorting features to yours.
-
02:10:36 These are good eats this Lehman's on using Entity framework for automatic. Display insert
-
02:10:48 update. Delete for example. We are doing sorting, but we can still change values. I'm going
-
02:11:00 to make this let's say 0 0 1 milligram. Okay.
-
02:11:08 So it's going to be at the top. So this is 15, 15 6 as an ID and use it as one modified.
-
02:11:16 Let's say. Okay, save it. Let's refresh. And you see novelties.
-
02:11:22 We'll finish it in the database so it is working.
-
02:11:25 I can also delete the ones that I want. For example, delete delete. Say, delete it and
-
02:11:33 refresh. Okay? After sorting feature,
-
02:11:40 How to bind all elements of an animation?
-
02:11:52 To a combo box box display description of any Malaysian of enemies and items in the
-
02:12:07 combo box.
-
02:12:10 Which Asians?
-
02:12:14 Description of any items in the combo box, okay?
-
02:12:29 how to get selected and liberation of
-
02:12:38 first ones combobox. Okay.
-
02:12:43 Okay, so we had to write this method to get the value or description of the illumination.
-
02:12:54 We also had to write this to add all the values of Animation dynamically. So, whatever I add
-
02:13:01 here, I don't need to change any other code. It will be fully automatic. Of course, I would
-
02:13:05 need to change the Sorting options and to be used is no, we don't use this but
-
02:13:12 let's remove this because it may come get you confused.
-
02:13:18 Okay, let's test it again. Okay. I will also get a new backup of the database so you can
-
02:13:29 use it.
-
02:13:32 What else did we do?
-
02:13:42 Looking operations.
-
02:13:47 Okay, let's login.
-
02:13:54 So in searching, the database was really slow, right? So I am going to
-
02:14:06 Make an optimization, okay.
-
02:14:13 What kind of optimization I am going to make you wonder that show you. Of course, this
-
02:14:19 would require some extra RAM memory but it should work because our bodies are not that
-
02:14:27 much big, not that big. So let me show you the
-
02:14:35 Optimization first, I will loads.
-
02:14:40 Okay to cage. How am I going to do that?
-
02:14:49 So this will load everything into the cage.
-
02:14:57 I think. Yeah. Then first, I will check the cage.
-
02:15:04 Then I will check the database.
-
02:15:11 Actually, I don't need even to check database. Okay. So
-
02:15:16 let's remove this because we are doing a full local caging. Let's see.
-
02:15:31 So it should load everything into database right here. Let's see how much time it will
-
02:15:39 increase. I mean, they should wrote everything in the database to the ram here. Then we don't
-
02:15:44 even need to check the database anymore because they will be in the local or not.
-
02:15:50 So, it will be pretty fast. Of course, it would require more RAM memory. If you had
-
02:15:56 millions of items, you can do that.
-
02:16:00 Okay, let's see. We are at the
-
02:16:05 okay, 700 megabytes.
-
02:16:08 And okay, we can see, we have got 120 megabytes, okay? It didn't even increase anything, I
-
02:16:16 don't know if it's pork.
-
02:16:20 Okay, let's see. Let's go to this Parts jump.
-
02:16:28 And oh, it was zero. So let's go here for example.
-
02:16:36 Okay, so there is 200 milligram. It is probably exists in the database already.
-
02:16:43 Okay. It was null because it did get it from the local cage. So let's see. The speed of
-
02:16:52 our algorithm.
-
02:16:57 Okay. It is still very slow. Oh, I know the reason because it is now, first parsing, the
-
02:17:07 first three chords above 3000, then it will start adding them.
-
02:17:14 Turn it is passing, so we can actually display two indexes stood at. Okay. So let's add this
-
02:17:28 counters.
-
02:17:29 You name it and then adds process account.
-
02:17:40 Okay, so for process it, it will get increases each time and process like this.
-
02:17:51 And let's display it here as well. Okay.
-
02:18:01 Rocks.
-
02:18:05 Okay. Yeah this. So we need to change it to here.
-
02:18:24 But if it is not added video continue of, I see so I also need to change this.
-
02:18:30 Let's change this as well.
-
02:18:37 yes, that's you know this
-
02:18:47 Let's see how fast we will versus records.
-
02:18:58 Okay.
-
02:18:59 Let's login.
-
02:19:02 Let's see.
-
02:19:05 Okay, so we are processing with this speech.
-
02:19:17 This file has so many.
-
02:19:25 Okay, so
-
02:19:29 this should have happened.
-
02:19:35 Because when we edit it should get into local.
-
02:19:56 okay, how many the three interesting
-
02:20:15 So probably this is get not getting into local cage.
-
02:20:19 So I also need to add this to local church perhaps let's see if this is if it in work.
-
02:20:40 Can we add to local?
-
02:21:02 Okay, and send to the 0 as well.
-
02:21:06 Let's see what happens. I'm not sure if this will work but it should work.
-
02:21:12 because first we are loading everything into the memory, then we are adding them to Local
-
02:21:31 and
-
02:21:32 Meanwhile, I will look something else too.
-
02:21:34 It's open Chrome.
-
02:21:37 Okay, and titov.
-
02:21:53 Versus.
-
02:22:07 Okay, so
-
02:22:20 yeah, it is not working.
-
02:22:30 I wonder why?
-
02:22:45 Get, there are 3498 numbers test, something. Let's put a breakpoint here.
-
02:23:16 Okay.
-
02:23:21 I think I believe this to Seoul next week. So meanwhile you can work on that until next
-
02:23:28 week and maybe you can figure out figure it out before me, so it will be also a nice working
-
02:23:37 for you. So,
-
02:23:39 We have in the local.
-
02:23:41 okay, 3498
-
02:23:43 which is a the seed, local.
-
02:23:53 Oh, I think I may know the reason.
-
02:23:58 So in here, so this is its name.
-
02:24:07 Maybe there is case sensitivity problem.
-
02:24:15 Just doesn't exist yet, okay?
-
02:24:26 Let's continue.
-
02:24:28 But it throws an error. Why?
-
02:24:37 There is no such record like this.
-
02:24:51 It says that there is a duplicate key.
-
02:24:57 Yeah, this is related to database itself. So,
-
02:25:05 But we'll do a like, really to see.
-
02:25:25 Okay, I see it already exists like this. So there is this difference coming from
-
02:25:36 So when I look for it like this, let's see if it will come.
-
02:25:44 I copy pasted it.
-
02:25:48 It doesn't come. Do you think why why do you think
-
02:25:52 But when I search like this, I see it is here.
-
02:25:58 As you see?
-
02:26:06 Because this drug names are encapsulated with.
-
02:26:15 Yeah, I know the reason because we didn't remove this.
-
02:26:19 So, I need to search them like this.
-
02:26:22 But I thought you'd like this.
-
02:26:26 Yeah, it's just here.
-
02:26:32 And let's see the futures of this one.
-
02:26:39 Okay, let's restart.
-
02:26:45 What may be causing his ever?
-
02:27:01 In this sea.
-
02:27:13 Zero points, 125.
-
02:27:25 Do we have that?
-
02:27:33 Yes, we have it.
-
02:27:40 But this one has different.
-
02:27:46 So, the rock name and those.
-
02:27:55 Okay, and then we go here. We only have one drug edits.
-
02:28:09 Yeah.
-
02:28:10 Let me stay with you just not working.
-
02:28:18 Why is that happening?
-
02:28:22 We see the
-
02:28:24 secret. It takes truck name and dose milligram.
-
02:28:37 So something is not right here.
-
02:28:43 Oh, I know the reason. Okay, I have figured out figured out, the reason I will leave it
-
02:28:52 to you and I want you to find it, okay?
-
02:28:57 Okay.
-
02:28:59 So, let's take some notes next week show. Why?
-
02:29:07 Is producing and 100 errors.
-
02:29:14 And it's searching future, okay? Okay, I want you to find out. Reason I have found it, so
-
02:29:26 I will take a backup of the database and added to our source code as well.
-
02:29:31 So, I will be able to use it exactly as me.
-
02:29:37 okay, let's go to our temporary folder and
-
02:29:40 That's this one. Okay, DB folder. Here's the Cebu. KMS.
-
02:29:53 Okay.
-
02:29:55 Back up.
-
02:29:57 Let's copy and paste this into our source code.
-
02:30:05 Lecture 9.
-
02:30:07 Here's okay. Let's push the
-
02:30:12 Repository.
-
02:30:24 Okay.
-
02:30:37 Okay, says it is larger but it is accepted. I think.
-
02:31:04 Let's check our repository to verify.
-
02:31:11 Okay, let's open our repository is
-
02:31:18 Yeah, it's updated lectures here. Lecture 9
-
02:31:26 Inside are static data. Yes. Okay. Everything is working. And thank you very much for watching.
-
02:31:32 Hope we'll see you next week and of lecture 9.
