LINQ to SQL automatically produces SQL statements to CRUD operations. Sometimes it may be preferable to use stored procedures to access data in order to improve application performance, guarantee security and inject some business logic.
Querying a database using Linq follows the same rules as querying in-memory objects (Linq To Objects): the only difference is that the database context object must be instantiated.
A Linq To SQL component can be added to a project following one of the step below: Visual Studio Designer using Linq attributes (.dbml file) Generate code and mappings (.xml file) / Linq attributes (.dbml file) through the SQLMetal.exe tool … Continue reading
Data model classes are normally definied following the strategy one classe-one table. An aternative strategy of modeling is to have an entity classes inheritance to be saved on the same table: a discriminator table column indicates what class type each … Continue reading
Linq To SQL permits to add custom logic, auditing or logging to each entiity: validation of global custom rules added to an entity before persisiting it’s values to the database; specific custom logic before each of the specific CUD operations … Continue reading
The mapping of each entity class of the Data Model to a database table is achived through the use of an external XML file.
Entity relationships are implemented in the code through the use of the generic types EntitySet<T> and EntitiyRef<T> whith are used to define the class members involved in the relationships.. Consequently, objects that refer to each other using property references or collections … Continue reading
The mapping of each entity class of the Data Model to a database table is achived through the use of attributes to decorate the class as well as class properties and class fields.
The Data Model is defined by a set of POCO classes where each of these classes represents a data table in the relational database and each object instance represents a row within the database table. These classes are referred to … Continue reading