Tutorial by Examples: di

Eager loading lets you load all your needed entities at once. If you prefer to get all your entities to work on in one database call, then Eager loading is the way to go. It also lets you load multiple levels. You have two options to load related entities, you can choose either strongly typed or st...
After turning Lazy loading off you can lazily load entities by explicitly calling Load method for entries. Reference is used to load single navigation properties, whereas Collection is used to get collections. Company company = context.Companies.FirstOrDefault(); // Load founder context.Entry(com...
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /$1/ [L,R=301] The first RewriteCond helps exclude the files. The second RewriteCond checks if there is already a trailing slash. If the case is so RewriteRule is not applied. If you have any URL that s...
Laravel's events allows to implement the Observer pattern. This can be used to send a welcome email to a user whenever they register on your application. New events and listeners can be generated using the artisan command line utility after registering the event and their particular listener in App...
Though the transaction class method is called on some ActiveRecord class, the objects within the transaction block need not all be instances of that class. This is because transactions are per-database connection, not per-model. In this example a balance record is transactionally saved even though ...
Both #save and #destroy come wrapped in a transaction that ensures that whatever you do in validations or callbacks will happen under its protected cover. So you can use validations to check for values that the transaction depends on or you can raise exceptions in the callbacks to rollback, includin...
The number that follows the associativity information describes in what order the operators are applied. It must always be between 0 and 9 inclusive. This is commonly referred to as how tightly the operator binds. For example, consider the following fixity declarations (in base) infixl 6 + infixl ...
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver class UserProfile(models.Model): user = models.OneToOneField(User, related_name='user') website = models.URLField(default='', ...
When either a signed or unsigned integer is converted to a signed integer type, and its value is not representable in the destination type, the value produced is implementation-defined. Example: // Suppose that on this implementation, the range of signed char is -128 to +127 and // the range of un...
Sometimes in a development or testing environment, the SSL certificate chain might not have been fully established (yet). To continue developing and testing, you can turn off SSL verification programmatically by installing an "all-trusting" trust manager: try { // Create a trust mana...
<svg xmlns="http://www.w3.org/2000/svg"> <switch> <text systemLanguage="en-UK" x="10" y="10">UK English</text> <text systemLanguage="fr" x="10" y="10">Français</text> <text ...
The SUBDIRS ability of qmake can be used to compile a set of libraries, each of which depend on another. The example below is slightly convoluted to show variations with the SUBDIRS ability. Directory Structure Some of the following files will be omitted in the interest of brevity. They can be a...
If you want to show local notification immediately, you should call: Swift 3 UIApplication.shared.presentLocalNotificationNow(notification) Swift 2 UIApplication.sharedApplication().presentLocalNotificationNow(notification) Objective-C [[UIApplication sharedApplication] presentLocalNotific...
#Region directive can now be placed inside methods and can even span over methods, classes and modules. #Region "A Region Spanning A Class and Ending Inside Of A Method In A Module" Public Class FakeClass 'Nothing to see here, just a fake class. End Class Module Extensi...
Here are all access modifiers in venn diagrams, from more limiting to more accessible: Access ModifierDiagramprivateinternalprotectedprotected internalpublic Below you could find more information.
In F# there are many options for creating data pipelines, for example: List, Seq and Array. What data pipeline is preferable from memory usage and performance perspective? In order to answer this we'll compare performance and memory usage using different pipelines. Data Pipeline In order to me...
By adding the following extension to array indices can be accessed without knowing if the index is inside bounds. extension Array { subscript (safe index: Int) -> Element? { return indices ~= index ? self[index] : nil } } example: if let thirdValue = array[safe: 2] { ...
#demo-element { background: @theme-color; color: contrast(@theme-color, black, white, 50%); } @theme-color: red; The above example will set the text color of the element as white if the background-color is dark and vice-versa. This is achieved using the contrast() color operation functi...
In Tcl, a control structure is basically just another command. This is one possible implementation of a do ... while / do ... until control structure. proc do {body keyword expression} { uplevel 1 $body switch $keyword { while {uplevel 1 [list while $expression $body]} u...
2.1.3 1. Preview Different Devices There is a preview panel at the right of the android studio. In thispanel there is a button with device name with which you are previewing the UI of your app like this . Click on small dropdown indicator of this and a floating panel will appear with all the pr...

Page 81 of 164