LinqConnect Documentation
In This Topic
    Attributes
    In This Topic

    The attributes applied to the columns and associations can impact the SQL generation.

    Column attributes

    In case when methods like AssociateWith() or Where() are used, the query will be built almost directly. The influence of attribute is not so obvious. Of course, some attributes influence the method behaviour directly. If the CanBeNull attribute is set to true, there will be a NULL check in the generated SQL.

    As for the IsDbGenerated attribute, if it is set to true, the property will not participate in the generated SQL (LINQ knows that DB is responsible for this column)

    The AutoSync attribute is handled a bit in other way. Column, having it set to any other value than "None", can take part in db query, but it will be queried (or returned, if DBMS has support for RETURNING clause) after the Insert (OnInsert) or update (OnUpdate) event occurs. If this attribute is set to Both, refresh will occur after either insert or update.

    The UpdateCheck attribute deals with optimistic concurrency issues. More information is available in MSDN in the Optimistic Concurrency Overview article. The functions of IsVersion attribute is close to the UpdateCheck ones. However, it influences the generated SQL more directly. If you have an IsVersion column then you will obtain a check in the SQL that will compare the value of the IsVersion column with the value in database and the update will fail in case if these values differ.

    Association attributes

    The influence of the association attributes differs a bit from the one of the column attributes. They define the kind of JOINs and other association-specific marvels of the SQL generation.

    Here we will take a look on a couple of attibutes — IsForeignKey and IsUnique.

    IsForeignKey IsUnique Influence
    false ignored No joins are generated
    true false Left join will be generated based on the association
    true true Inner join will be generated based on the association