Tutorial by Examples: er

Projection refers to the operations of transforming an object into a new form. Select Projects values that are based on a transform function. Method Syntax // Select var numbers = new int[] { 1, 2, 3, 4, 5 }; var strings = numbers.Select(n => n.ToString()); // strings = { "1...
A sorting operation orders the elements of a sequence based on one or more attributes. OrderBy Sorts values in ascending order. Method Syntax // OrderBy var numbers = new int[] { 5, 4, 8, 2, 7, 1, 9, 3, 6 }; var ordered = numbers.OrderBy(n => n); // ordered = { 1, 2, 3, 4, 5, 6, ...
Conversion operations change the type of input objects. AsEnumerable Returns the input typed as IEnumerable. Method Syntax // AsEnumerable int[] numbers = { 1, 2, 3, 4, 5 }; var nums = numbers.AsEnumerable(); // nums: static type is IEnumerable<int> Query Syntax // Not app...
Aggregation operations computes a single value from a collection of values. Aggregate Performs a custom aggregation operation on the values of a collection. Method Syntax // Aggregate var numbers = new int[] { 1, 2, 3, 4, 5 }; var product = numbers.Aggregate(1, (acc, n) => acc * n);...
Quantifier operations return a Boolean value that indicates whether some or all of the elements in a sequence satisfy a condition. All Determines whether all the elements in a sequence satisfy a condition. Method Syntax // All var numbers = new int[] { 1, 2, 3, 4, 5 }; bool areLessThan...
Grouping refers to the operations of putting data into groups so that the elements in each group share a common attribute. GroupBy Groups elements that share a common attribute. Method Syntax // GroupBy class Order { public string Customer { get; set; } public string Descriptio...
Partitioning refers to the operations of dividing an input sequence into two sections, without rearranging the elements, and then returning one of the sections. Skip Skips elements up to a specified position in a sequence. Method Syntax // Skip var numbers = new int[] { 1, 2, 3, 4, 5 }; ...
Generation refers to creating a new sequence of values. DefaultIfEmpty Replaces an empty collection with a default valued singleton collection. Method Syntax // DefaultIfEmpty var nums = new int[0]; var numbers = nums.DefaultIfEmpty(); // numbers = { 0 } Query Syntax // Not appl...
Set operations refer to query operations that produce a result set that is based on the presence or absence of equivalent elements within the same or separate collections (or sets). Distinct Removes duplicate values from a collection. Method Syntax // Distinct var numbers = new int[] { 1,...
Two sequences whose corresponding elements are equal and which have the same number of elements are considered equal. SequenceEqual Determines whether two sequences are equal by comparing elements in a pair-wise manner. Method Syntax // SequenceEqual var numbers1 = new int[] { 1, 2, 3, 4,...
Element operations return a single, specific element from a sequence. ElementAt Returns the element at a specified index in a collection. Method Syntax // ElementAt var strings = new string[] { "zero", "one", "two", "three" }; var str = strings.E...
To generate an ActiveRecord model that automagically creates the correct db migrations & boilerplate test files for your model, enter this command rails generate model NAME column_name:column_type 'NAME' is the name of the model. 'field' is the name of the column in the DB table and 'type' i...
When you bind a service to your application credentials become available through the VCAP_SERVICES environment variable. This environment variable contains JSON containing the credentials for all bound services. Example VCAP_SERVICES environment variable { "push-reappt": [ { ...
Filters format the value of an expression for display to the user. They can be used in view templates, controllers or services. This example creates a filter (addZ) then uses it in a view. All this filter does is add a capital 'Z' to the end of the string. example.js angular.module('main', []) ...
Stream is especially useful when you want to run multiple operations on a collection. This is because Stream is lazy and only does one iteration (whereas Enum would do multiple iterations, for example). numbers = 1..100 |> Stream.map(fn(x) -> x * 2 end) |> Stream.filter(fn(x) -> rem(x...
This example is a snippet taken from the Extending Django User Profile like a Pro from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneToOneField(User, related_name='user'...
Classic unit tests test state, but it can be impossible to properly test methods whose behavior depends on other classes through state. We test these methods through interaction tests, which verify that the system under test correctly calls its collaborators. Since the collaborators have their own...
To enable a certain CORS policy for specific controllers you have to build the policy in the AddCors extension within the ConfigureServices method: services.AddCors(cors => cors.AddPolicy("AllowAll", policy => { policy.AllowAnyOrigin() .AllowAnyMethod() ...
One of the major benefit of Fourier Transform is its ability to inverse back in to the Time Domain without losing information. Let us consider the same Signal we used in the previous example: A1=10; % Amplitude 1 A2=10; % Amplitude 2 w1=2*pi*0.2; % Angular f...
Let's say we have a simple table called person: CREATE TABLE person ( person_id BIGINT, name VARCHAR(255). age INT, city VARCHAR(255) ); The most basic insert involves inserting all values in the table: INSERT INTO person VALUES (1, 'john doe', 25, 'new york'); If you wa...

Page 102 of 417