EF Core Migrations is a feature that helps manage database schema changes. It allows developers to easily create, update, and rollback database migrations using a code-first approach, ensuring that your database schema stays in sync with your application models.
This set outlines how to construct a filter for the User Object Filter and Group Object Filter attributes in an LDAP configuration.
(&(objectClass=user)(cn=Mark*))
This means: search for all entries that have objectClass=user AND cn that start with the word 'Mark'.
A C# method can be called with invalid arguments, this may cause an ArgumentException.
ArgumentException indicates that a method was called with an invalid argument. This can help improve program quality.
ArgumentException is thrown when a method is invoked and at least one of the passed arguments does not meet the parameter specification of the called method. The ParamName property identifies the invalid argument.
When using the ArgumentNullException constructor, you can pass a string literal indicating the null argument.
The time service in Windows can be reset to a default state by running the following inside an elevated Command Prompt (CMD):
net stop w32time
w32tm /unregister
w32tm /register
net start w32time
To verify the time server, follow these steps:
timedate.cpl
time.windows.com
)Scrum is an empirical process control framework.
Empirical means to runs experiments to improve the product.
Meetings in Scrum
Additional meetings
You can use the following code snippets to get a class's public methods using reflection. The class name is provided as typeName
.
MethodInfo[] methodInfos = typeof(Class).GetMethods();
Variant with filter using BindingFlags
MethodInfo[] methodInfos = Type.GetType(typeName)
.GetMethods(BindingFlags.Public | BindingFlags.Instance);
You can use this code to get only the methods decorated with a custom attribute.
MethodInfo[] methodInfos = assembly.GetTypes()
.SelectMany(t => t.GetMethods())
.Where(m => m.GetCustomAttributes(typeof(CustomAttribute), false).Length > 0)
.ToArray();
Here’s an example of how to invoke a private method using reflection in .NET:
MyClass myClass = new MyClass();
Type classType = myClass.GetType();
MethodInfo methodInfo = classType.GetMethod("MethodName",
BindingFlags.Instance | BindingFlags.NonPublic);
// Make an invocation:
var result = await (dynamic)methodInfo.Invoke(myClass, null);
TanStack Query is a data-fetching library for React applications. It simplifies communication with APIs by abstracting complex logic into simple queries. With TanStack Query, you can define queries using plain JavaScript objects, leverage caching and automatic refetching, handle pagination, and easily manage loading and error states. It enhances productivity and improves the data-fetching experience in React projects.
To use useState, you must first import it from the React library. Then you can call the useState function with an initial value for your state variable. This will return an array with two elements: the current value of the state variable and a function that you can use to update that value.
For example, let's say you want to create a counter that increments each time a button is clicked. You could use useState to create a state variable for the count like this:
import React, { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
const handleClick = () => {
setCount(count + 1);
};
return (
<div>
<p>You clicked {count} times</p>
<button onClick={handleClick}>Click me</button>
</div>
);
}
In this example, we're using the useState hook to create a state variable called count
, which is initially set to 0. We're also defining a function called handleClick
that updates the count variable by calling the setCount
function with the new value of count + 1
. Finally, we're rendering the current value of count
in a paragraph tag, along with a button that calls the handleClick
function when clicked.
HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.
The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is, no side effect), whereas successive identical POST requests may have additional effects, akin to placing an order several times.
It is possible to use PUT without a body like
PUT /example HTTP/1.0
Content-Type: text/plain
Content-Length: 0
A sample would be the github starring API, which uses PUT with an empty body to turn on a star and DELETE to turn off a star.
You can get private property like so:
Class class = new Class();
var privateProperty = class.GetType().GetProperty("privateProperty", BindingFlags.Instance | BindingFlags.NonPublic);
int propertyValue = (int) privateProperty.GetValue(class);
var privateField = class.GetType().GetField("privateField", BindingFlags.Instance | BindingFlags.NonPublic);
int fieldValue = (int) privateField.GetValue(class);
Entity Framework Core 5 is the first EF version to support filtering in Include
.
Supported operations are Where
, OrderBy
(Descending)/ThenBy
(Descending), Skip
, Take
Some usage example
context.Customers
.Include(c => c.Orders.Where(o => o.Name != "Foo")).ThenInclude(o => o.OrderDetails)
.Include(c => c.Orders).ThenInclude(o => o.Customer)
Only one filter is allowed per navigation, so for cases where the same navigation needs to be included multiple times (e.g. multiple ThenInclude on the same navigation) apply the filter only once, or apply exactly the same filter for that navigation.
In the example below, we have a list of numbers. The ForEach method is called on the list and a lambda expression num => Console.WriteLine(num) is passed as the argument. This lambda expression takes each element num from the list and prints it using Console.WriteLine. The lambda acts as the action to be performed on each element in the list.
var numbers = new List<int> { 1, 2, 3, 4, 5 };
numbers.ForEach(num => Console.WriteLine(num));
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
Spread operator doing concat
let arrayOne = [1, 2, 3];
let arraryTwo = [4, 5];
arrayCombined = [...arrayOne,...arrayTwo];
Add item using spread operator
let arrayOne = [1, 2, 3];
arrayNew = [...arrayOne, 3];
Event handlers determine what action is to be taken whenever an event is fired. This could be a button click or a change in a text input.
You would write this as follows in React:
function ActionLink() {
const handleClick = (e) => {
e.preventDefault();
console.log('The link was clicked.');
}
return (
<button onClick={handleClick}>Click me</button>
);
}
Inline functions allow you to write code for event handling directly in JSX. See the example below:
import React from "react";
const App = () => {
return (
<button onClick={() => alert("Hello!")}>Say Hello</button>
);
};
export default App;
Another common use case for event handlers is passing a parameter to a function in React so it can be used later. For example:
import React from "react";
const App = () => {
const sayHello = (name) => {alert(`Hello, ${name}!`);
};
return (
<button onClick={() => {sayHello("John");}}>Say Hello</button>
);
};
export default App;
This is an elementary guide to Git for beginners. Git is a version-control system for tracking changes in files associated with projects of different types. It is primarily used for source-code management in software development, but it can be used to keep track of changes in any set of files.
Without a version control system, you probably used to frequently save copies of your work-in-progress in zip files. But when you feel that your work is a mess and you need to get back to a previous version of some files, how to deal with mixed changes in files? It’s a real pain to do that. Git and other version control systems like SVN are a great solution.