I was looking at a dbml file in xml editor and noticed that some of the properties had a storage field and some did not. I also noticed that some had name, which I assuming is the name of the field in sql. If the property in the dbml file has a dif开发者_Python百科ferent name from the one in sql, it will add the member attribute. I don't understand why some fields have a storage attribute and some do not?
From MSDN
**DataAttribute.Storage Property**
Gets or sets a private storage field to hold the value from a column.
Have a look here
Sometimes the field in the database has a name that is not overly helpful in explaining what it does and so a programmer will change the name in the code to help them remember what it is for and add the Name parameter to tell Linq that it is actually stored someplace else.
What the Storage property does is allow you to put business logic into the public field accessors and still allow Linq to access the data directly without going through that business logic. This way Linq will not run your business code each time, it will just load and save the data from your private storage variable.
See: http://msdn.microsoft.com/en-us/library/bb386940.aspx
精彩评论