Total Microtheories:7420 TotalHits: 243623 Email Us | Add MT | Help Using the Site


[Valid RSS] | RSS Feed

Most Recent Microtheory

(hits=1) The disadvantage of Async all the way down with IQueryable is you use memory resource to build the collections. If the collections are large than your server resource is consumed.[Learn More...]
(hits=2) This snippet demonstrates how to use IQueryable to return data to a module method. IQueryable is an IEnumerable derived class meaning it allows you to foreach items in the collection. IQueryable does not retrieve data from the database until it is being enumerated. This allows you to retrieve large datasets and process the items in the dataset. IQueryable does not have an awaiter, so making it async is possible but not by design. To make it async you would convert the query to a list collection by type and return the list as AsQueryable.[Learn More...]
(hits=4) @""" are used to create one quote in json. A single @" is used to separate and start the c# code parsing to be inserted into the json string data.[Learn More...]
(hits=5) Newtonsoft JsonConvert.DeserializeObject is used to deserialize the json structure into the class objects. The JSON view in the debugger is helpful to know whether your json string has been formatted correctly.[Learn More...]
(hits=6) This code snippet demonstrates how to create a json string that can be deserialized into a class and class list encapsulated in the parent class. A purchaseOrderView contains a list of PurchaseOrderDetailViews. The unitOfWork will use the purchaseOrderView to create the purchase order and its details in the sql table. I demonstrate how to create a json string in c# in this demonstration. I bind information from the SupplierView, Company, and 5 item master objects into the json. The unit of work will do all the rollup calculations before writing to the database.[Learn More...]
(hits=6) 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=6) 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=17) 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=20) 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=21) 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=24) 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=233) The App.XML is initialized with a Boostrapper entry point. The Bootstrapper loads the mainViewModel and its view.[Learn More...]
(hits=30) 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=27) 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=35) 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=30) 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=30) 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=37) 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=48) 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=30) 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=32) 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=32) 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=31) 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=34) The Lambda parameters can be passed by reference (ref int x). The x increment is permanent.[Learn More...]
(hits=48) Lambda expression take parameters (Person p). If no parameter are given then use () indicating an empty parameter list.[Learn More...]
(hits=36) 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...]

Top 20 Microtheories

Top 5 Questions

Recent Questions