简体   繁体   English

C#LINQ To SQL类

[英]C# LINQ To SQL Classes

I made a LINQ to SQL Classes file DataClasses.dbml . 我制作了一个LINQ to SQL Classes文件DataClasses.dbml When i drag a table in it is ok and everything works but I was wondering can i put to columns together using the Source property where the column name is passed? 当我将表格拖到里面就可以了,并且一切正常,但是我想知道我是否可以使用传递列名称的Source属性将列放在一起? example Name+Surname 示例名称+姓氏

Memeber房地产

No you can't do it, becouse in property window you can just write name of one column that will be bind your property. 不,您不能这样做,因为在属性窗口中,您只需编写将绑定属性的一列名称即可。 It's just to this ORM Framework works. 仅此ORM框架有效。

However you can do it other way. 但是,您可以采用其他方式。

First way is to extend your table class becouse all classes in .dbml autogenerated file are partial . 第一种方法是扩展表类, .dbml自动生成的文件中的所有类都是partial So you can write property with return Name + Surname; 因此,您可以使用return Name + Surname;来编写属性return Name + Surname;

Second way is to write stored procedure in your database that returns NameAndSurname field and drop it to your .dbml file like you already have done with table. 第二种方法是在存储数据库中编写存储过程,该存储过程返回NameAndSurname字段,然后像对待表一样将其拖放到.dbml文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM