假设您有一个类似以下的模式
Say you have a schema that looks something like this
Foo FooId Bar BarId SomeFooId // Foreign key to Foo.FooId AnotherFooId // Foreign key to Foo.FooId我希望能够执行以下操作:
I would like to be able to do something like this:
Bar bar = ... DoSomethingWith(bar.SomeFoo); DoSomethingElseWith(bar.AnotherFoo);但是,不是生成 SomeFoo 和 AnotherFoo 属性中,linq-to-sql设计器生成 Foo 和 Foo1 。 Foo 和 Foo1 中哪个引用 SomeFoo ,并引用 AnotherFoo 。有什么方法可以手动为这些属性指定名称,以便我可以将它们称为 SomeFoo 和 AnotherFoo ?
However, instead of generating SomeFoo and AnotherFoo properties, the linq-to-sql designer generates Foo and Foo1. It is not obvious which of Foo and Foo1 refers to SomeFoo, and which refers to AnotherFoo. Is there any way to manually specify a name for these properties, so that I can refer to them as SomeFoo and AnotherFoo?
我在Visual Studio 2010中使用dbml设计器,而Visual Studio 2008也有相同的问题。
I am using the dbml designer in Visual Studio 2010, and I had the same problem with Visual Studio 2008.
推荐答案您可以在Linq to SQL设计器中编辑名称。只需单击要重命名的字段,按 F4 ,然后更改 Name 属性。
You can edit the names in the Linq to SQL designer. Just click on the field you want to rename, press F4, and change the Name Property.
或者,您可以单击要重命名的字段,然后开始输入新名称。
Alternatively, you can click on the field you want to rename, and just start typing the new name.
因此,您要修改为外键生成的便利属性的名称。
So you want to modify the names of the "convenience properties" that are generated for the foreign keys.
编辑:
我知道了。在LINQ to SQL设计器中,单击关联(将两个关联表连接在一起的行),展开父属性树,并更改 Name 属性。这将影响便利属性的生成名称。
I figured it out. In the LINQ to SQL designer click on the association (the line connecting the two associated tables together), expand the "Parent Property" tree and change the Name Property. This will affect the generated name of the "convenience property".
更多推荐
有什么方法可以控制linq
发布评论