Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is DBML storage attribute in LINQ to SQL?

Tags:

database

linq

I am currently working on a project that uses LINQ to SQL for database access. It has become necessary for me to manually update the DBML file by right-clicking on it and opening it with an XML editor because I do not want to re-generate the file and lose all of the changes that have been made to association member names.

Can someone please explain to me what the storage attribute is used for in the Association element of the DBML file? I have searched this forum and Google to no avail. The storage attribute is not present in every Association element. I have included XML in my DBML that both includes and excludes the storage attribute below:

  <Association Name="Customer_WorkOrder" Member="Customer" ThisKey="CustomerId" OtherKey="Id" Type="Customer" IsForeignKey="true" />

  <Association Name="Sycode_WorkOrder" Member="WorkOrderOrderStatus" Storage="_Sycode" ThisKey="OrderStatus" OtherKey="recno" Type="Sycode" IsForeignKey="true" />
like image 548
Grasshopper Avatar asked Feb 17 '12 02:02

Grasshopper


People also ask

What is Dbml in LINQ to SQL?

The LINQ to SQL is the component of . NET Framework version 3.5. It provides the run time infrastructure to manage the relational data as objects. It allows us to access and get the data from the SQL database with LINQ queries.

What is difference between Dbml and EDMX?

edmx is the modeling file for Entity Framework. dbml is the modeling file for Linq 2 Sql. You should spend your time learning Entity Framework as Linq 2 Sql is deprecated.

How do I add a stored procedure to an existing Dbml?

To add stored procedures to the O/R Designer dbml file that you added earlier. Click the Sales by Year stored procedure and drag it to the right pane of the designer. Click the Ten Most Expensive Products stored procedure drag it to the right pane of the designer. Save your changes and close the designer.

How do I create a Dbml file?

In Visual Studio, right click on your project in the Solution Explorer, on the folder where you want to add the DBML. Choose Add New Item, then under Data, choose Linq-To-SQL Classes . This will create an empty DBML file.


1 Answers

http://msdn.microsoft.com/en-us/library/system.data.linq.mapping.dataattribute.storage.aspx


Gets or sets a private storage field to hold the value from a column.

If there is no value set, it generates the private field like "_" + AssociationName, otherwise it uses the "storage" value. It is a bit confusing, since usually the "storage" term refers to the database and not to the generated code.

like image 77
Adrian Iftode Avatar answered Sep 28 '22 11:09

Adrian Iftode