Total Microtheories:7425 TotalHits: 244321 Email Us | Add MT | Help Using the Site


[Valid RSS] | RSS Feed

Most Recent Microtheory

(hits=4) The fluentAddressBookQuery has an method called GetAddressBooksByExpression which accepts an delegate function of type AddressBook. Linq expressions can be passed as a delegate function to the repository dataset through unit of work. AddressBookRepository inherits from the generic parent class repository of type T as addressBook. This allows you to call GetObjectsQueryable of the parent class repository from the derived class addressBookRepository. The delegate function is applied as a predicate to the dataset of data context.[Learn More...]
(hits=5) This code snippet demonstrates how to invoke an IQueryable using fluent Api. The FluentAddressBook class is encapsulated within the AddressBookModule class. The AddressModule class may contain one or more Fluent classes. Each Fluent class can represent a domain of work. When I call the Query api of the fluentaddressbook class, the object is instantiated. It is important for you to remember that you can not call Apply() within a foreach. Entity Framework conflicts with the IEnumerable thread of the foreach and an error will be thrown.[Learn More...]
(hits=6) The Unit of Work and its repository objects do all the entity frame work of creating, updating, deleting, and querying data from the database. The fluentCustomerQuery contains a set of collections of different types which can be loaded by parameter passing or by generic expressions invokes. I will demonstrate, how to use an lambda expression invoke to apply to a collection in my next sample. The ICustomerQuery Query() is defined in the FluentCustomer concrete class. It returns a ICustomerQuery type because the fluentCustomerQuery class is derived from ICustomerQuery. You now can chain the methods of the fluentCustomerQuery class which has the WithAccountsReceivable, WithCustomerLedgers, ..etc methods. I use property getters to access the collections of type T from the fluentCustomerQuery instance.[Learn More...]
(hits=6) The Customer Interface defines all the chain methods in the FluentCustomer concrete class. In this use case, I only deal with a cashpayment. The invoice Module was used to create the account receiveable from an invoice. The modules represent the useage of the fluent api concrete classes. If I need to create an accounts receivable entry without an invoice than I would add the fluentaccountreceivable class to the module.[Learn More...]
(hits=7) Fluent API makes your code more discoverable and much more easier to read. The complexity of the code is insulated in the concrete classes. Chaining methods is a helpful technique for understanding complex processes. In my code sample, I demonstrate how to create a Customer account. The customer account will use a login password was a data link. First, we create the address book, next we associated an email with the address book, then we create the customer record, and link the customer location address to the customer. Fluent API makes communication of what the object methods do more natural. The ICustomerModule Interace only has one definition ICustomer Customer() which returns a fluentCustomer object. The self reference to ICustomer by the FluentCustomerModule allows chaining. FluentCustomerModule derives from ICustomerModule allowing chaining to Customer(). Once the fluentCustomer has been instantiated than we can access all of its chained methods.[Learn More...]
(hits=6) 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=11) 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=9) @""" 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=9) 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=10) 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=10) 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=11) 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=23) 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=28) 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=38) 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=40) 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=243) The App.XML is initialized with a Boostrapper entry point. The Bootstrapper loads the mainViewModel and its view.[Learn More...]
(hits=49) 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=46) 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=54) 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=35) 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=48) 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=56) 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=51) 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=48) 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=36) 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...]

Top 20 Microtheories

Top 5 Questions

Recent Questions