Total Microtheories:7415 TotalHits: 243261 Email Us | Add MT | Help Using the Site


[Valid RSS] | RSS Feed

Most Recent Microtheory

(hits=0) This code snippet demonstrates how use linq to aggregate an summed amount on the general ledger. Remember to use the base method GetObjectsAsync to get the AcctRec record to the avoid the entity framework duplicate id error. The amount is group by the the document number and the amount is summed into a variable called Amount paid. The open amount then is the total amount of the invoice less the amount paid to date less discount if applicable.[Learn More...]
(hits=1) This code snippet demonstrates how to use the BeginTransaction to update a table preventing another user from changing values in the critical path while the method is running. The transaction is committed and the change occurrs in the table. However, we don't want to commit the context changes from the context because commits should be done at the unit of work level. Therefore, NextNumber data manipulation should be moved to a stored procedure with transaction table locking. SQLQuery and sqlparameter allows you to call a store procedure within a unit of work critical path.[Learn More...]
(hits=12) The cancallation token stop one or all threads from executing. Each Task.Run can have a global cancellation token passed as a parameter. In the following example, three threads are created to produce a list of numbers for squared, cubed, and quadric numbers. The threads are launched sychronously or non blocked threads and the ui waits all the threads to complete. Each thread block is processed by a ContinueWith lambda function. The lambda function checks if the result set has been canceled before proceeding. The thread tasks for each of the tasks checks if the thread has been cancelled. If the task has been cancel than it does not need to wait for thread completion.[Learn More...]
(hits=18) The use of the abstract factory pattern will allow millions of developers to participate in building of my Millennium ERP without having to contend for resource. Contention is not of God, therefore, we must build abstract models that reduce programmer contention.[Learn More...]
(hits=18) From my unit of work repository pattern, I invoke the GetEmployeesBySupervisorId method which returns a list of EmployeeView objects. Within the GetEmployeesBySupervisorId method I use linq code to extract a query resultset of employees. Each employee is mapped to the employeeview business view class by use of the abstract factory using the business view class constructor. The Abstract factory has two abstract methods which with overrides in the concrete application class: MapSupervisorView and MapEmployeeView. The result is separation of concerns. The result is the implementation of the concrete class is hidden from the client.[Learn More...]
(hits=22) The abstract factory pattern delegates responsiblity of instantiation of the concrete class to another object. The abstract factory can have several different type of factories that it requests object generation with. In this example, I have built an BusinessView Factory for mapping my entity framework class data generated by code first into my business view classes.[Learn More...]
(hits=226) The App.XML is initialized with a Boostrapper entry point. The Bootstrapper loads the mainViewModel and its view.[Learn More...]
(hits=20) A usercontrol containing a textbox and a datagrid is loaded into the MainWindow view on the addressbook button click. The textbox x:Name="SearchName" is connected to the AddressViewModel Property SearchName. The x:Name="AddressBooks" is connected to the databindable AddressViewModel property AddressBooks, a databindablecollection. When an user enters data into the textbox, a text change event is raised and the AddressBookViewModel SearchName setter is invoked assigning the value to the _searchName variable. When the user presses the SearchButton, the Search method in the addressviewModel is called an the repository loads the databindablecollection with addressbook items.[Learn More...]
(hits=18) We are using caliburn for the mvvm architecture. Caliburn create a bootstrapper entry point. The MainViewModel is loaded with a mainview.xaml. The mainview has a grid for containing a button. The button will be used to activate the AddressViewModel through an LoadAddressBook button click event. The views and the viewmodels are connected by naming convention. The XXXviews are stored in the view directory and the XXXviewModels are stored in the ViewModels directory[Learn More...]
(hits=25) The Model View View model architecture allows for two way binding. In other words, Data changed in a datagrid will bind to data in an databindable collection and data changed in a databindable collection will bind with the datagrid, automatically. The MVVM model simplifies interaction with the datagrid.[Learn More...]
(hits=24) In the child window, I use the SingletonForm GetInstance to get the MainWindow instance by type and access its controls by name retrieving a combo box item data by using the comboboxitem class.[Learn More...]
(hits=20) WPF uses the app.xaml to launch the mainwindow.xaml using a starturi. Remove the starturi application attribute and replace it with an override method of OnStartup. In OnStartup use the extension class FormSingleton to invoke the instance of the MainWindow form and then display with the .Show method. Pass null as an owner since MainWindow is the root window. On the MainWindow I created a button for launching a child window form.[Learn More...]
(hits=26) I use a Singleton pattern to instantiate all forms in my application. I can access the form by its type. This model does not allow for multiple forms to be instantiated of the same type. The form type and the instance of the form are stored into a static dictionary. The Activator.CreateInstance will instantiate an instance of the form using its type. The owner is passed by argument as a parameter to the FormSingleton class. When the instance of the form is closed, a delegate function is callbacked an the form is removed from the static dictionary called dictForms.[Learn More...]
(hits=38) When objects are added, removed, or updated from the ObservableCollection the dataGrid is automatically updated with those changes. WPF adds a CollectionChanged event handler to the ObservableCollection's events.[Learn More...]
(hits=19) In this code snippet, I demonstrate how to use WPF XAML to display "Is A" data in one datagrid and "Has A" data in another datagrid for the dog class (see How to create concrete classes with polymorphism). XAML allows the developer to place wpf controls within a Grid or a Canvas. The grid allows the window to be partition into rows and columns. In this case there is only one row and one column by default for the grid. Within the grid is a combobox control with three values: Dog, Cat and Horse. Two data grids are defined within the grid relative position to the row top and column left position, they reside in. The dataGridIsA has one column which is data bound to an observable collection with the class field name of "IsAString". An ObservableCollection is a dynamic collection of objects of a given type. The IsA observableCollection contains data attributes of both the mammal abstract class and the dog class either from the ICollection or method calls. Additionally, the dataGridHasA is data bound to the observable collection holding the IsA ICollection attributes of the dog class. The AutoGenerate attribute of the dataGrid is set to false preventing the application from creating a data grid column from the observablecollection class variable names.[Learn More...]
(hits=23) The dynamic key word is used to create an anonymous class using a key/value pair combination of fieldname and value. The type is determined by the compiler.[Learn More...]
(hits=22) This code sample demonstrates how to implement polymorphism in c#. Polymorphism is one of the three pillars of object orient programming. Polymorphism means several forms. A dog is an mammal. The mammal class is defined as abstract meaning it can not be instantiated. However, the properties and methods of the abstract class can be accessed by the derived concrete class. An abstract class instance can reference a derived concrete class, but a concrete class can not reference an abstract class. Mammal mammal=dog is allowed but Dog dog=mammal is not. Polymorphism can be implemented by abstract GetSound method with the override GetSound method in the Dog class. Additionally, the Dog class constructor can be have multiple parameter types allowing for different behavior and attributes of the concrete class.[Learn More...]
(hits=27) he Lambda expression body can be made of multiple statements, variable assignments, or method calls. The lambda expression can modify class variables external to the expression, be careful.[Learn More...]
(hits=25) The Lambda parameters can be passed by reference (ref int x). The x increment is permanent.[Learn More...]
(hits=38) Lambda expression take parameters (Person p). If no parameter are given then use () indicating an empty parameter list.[Learn More...]
(hits=27) In this code snippet, I demonstrate how to create a list using a struct and how too use an enumeration type called GenderType in the struct. A list of Person struct type is created and a lambda function is created as the predicate of the Find extension and the FindAll extension. The Find extension searches the list until the first record with a match is encounter then stops. The FindAll extension searches the list for all matches returning true.[Learn More...]
(hits=36) await function().ConfigureAwait(false) will run the method on a separate thread from the UI thread. The await call will instantaneous return control back to the UI thread. In the code example, the doLongRunningFnc1 processes a 100 numbers raise to the third power without blocking the UI thread.[Learn More...]
(hits=26) The task returns a list of doubles for TResult. I can enumerate the Result because it is IList of doubles[Learn More...]
(hits=28) The await keyword in the async method specifics a point the c# compiler can split the code into a continuation on the thread doing the work.[Learn More...]
(hits=26) When the c# compiler encounters an await in an async method, it reformats it into a task.Run on the same thread as the async method. Now, there is a problem updating the User Interface because they share the same thread. Using the await on a code will create a continuation block for completion after the async code is done. You won't get a "marshalled from a different thread" error by using await with async or using continueWith and putting your UI update code in the continueWith code block.[Learn More...]
(hits=32) Mark Davis use manganese oxide to keep heat based hydrogen temperatures to 850 c versus 1000 c.[Learn More...]

Top 20 Microtheories

Top 5 Questions

Recent Questions