Tutorial by Examples: attribut

with Ada.Text_IO; procedure Main is X : Float := 2.71; begin Ada.Text_IO.Put_Line (Float'Image (X)); end Main; Result 2.71000E+00
Using .NET's rich reflection APIs, you can gain access to an assembly's metadata. For example, you can get this assembly's title attribute with the following code using System.Linq; using System.Reflection; ... Assembly assembly = typeof(this).Assembly; var titleAttribute = assembly.GetCust...
Let's take a sample class. class Book: def __init__(self, title, author): self.title = title self.author = author book1 = Book(title="Right Ho, Jeeves", author="P.G. Wodehouse") In Python you can access the attribute title of the class using the dot ...
Specifies a numeric minimum and maximum range for a property using System.ComponentModel.DataAnnotations; public partial class Enrollment { public int EnrollmentID { get; set; } [Range(0, 4)] public Nullable<decimal> Grade { get; set; } } If we try to insert/upd...
Specifies how the database generates values for the property. There are three possible values: None specifies that the values are not generated by the database. Identity specifies that the column is an identity column, which is typically used for integer primary keys. Computed specifies that th...
By Code-First convention, Entity Framework creates a column for every public property that is of a supported data type and has both a getter and a setter. [NotMapped] annotation must be applied to any properties that we do NOT want a column in a database table for. An example of a property that we ...
[Table("People")] public class Person { public int PersonID { get; set; } public string PersonName { get; set; } } Tells Entity Framework to use a specific table name instead of generating one (i.e. Person or Persons) We can also specify a schema for the table using [T...
public class Person { public int PersonID { get; set; } [Column("NameOfPerson")] public string PersonName { get; set; } } Tells Entity Framework to use a specific column name instead using the name of the property. You can also specify the database data type a...
public class Person { public int PersonID { get; set; } public string PersonName { get; set; } [Index] public int Age { get; set; } } Creates a database index for a column or set of columns. [Index("IX_Person_Age")] public int Age { get; set; } This creates ...
When a single parameter is passed to the .attr() function it returns the value of passed attribute on the selected element. Syntax: $([selector]).attr([attribute name]); Example: HTML: <a href="/home">Home</a> jQuery: $('a').attr('href'); Fetching data attributes: jQue...
If you want to add an attribute to some element you can use the attr(attributeName, attributeValue) function. For example: $('a').attr('title', 'Click me'); This example will add mouseover text "Click me" to all links on the page. The same function is used to change attributes' values...
To remove an attribute from an element you can use the function .removeAttr(attributeName). For example: $('#home').removeAttr('title'); This will remove title attribute from the element with ID home.
Specifies custom foreign key name if a foreign key not following EF's convention is desired. public class Person { public int IdAddress { get; set; } [ForeignKey(nameof(IdAddress))] public virtual Address HomeAddress { get; set; } } This can also be used when you have multipl...
C.I.A.s are intended as a simple way of getting attributes from whatever is calling the targeted method. There is really only 1 way to use them and there are only 3 attributes. Example: //This is the "calling method": the method that is calling the target method public void doProcess() ...
using System.ComponentModel.DataAnnotations; public class Post { public int Id { get; set; } [StringLength(100)] public string Title { get; set;} [StringLength(300)] public string Abstract { get; set; } public string Description { get; set; } } Def...
[TimeStamp] attribute can be applied to only one byte array property in a given Entity class. Entity Framework will create a non-nullable timestamp column in the database table for that property. Entity Framework will automatically use this TimeStamp column in concurrency check. using System.Compon...
This attribute is applied to the class property. You can use ConcurrencyCheck attribute when you want to use existing columns for concurrency check and not a separate timestamp column for concurrency. using System.ComponentModel.DataAnnotations; public class Author { public int AuthorId { ...
The Range attribute can decorate any properties or public fields and specifies a range that a numerical field must fall between to be considered valid. [Range(minimumValue, maximumValue)] public int Property { get; set; } Additionally, it accepts an optional ErrorMessage property that can be us...
The [RegularExpression] attribute can decorate any properties or public fields and specifies a regular expression that must be matched for the property be considered valid. [RegularExpression(validationExpression)] public string Property { get; set; } Additionally, it accepts an optional ErrorM...
You should use this when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with _confirmation appended. ...

Page 5 of 10