将名字字段和姓氏字段组合为全名以进行组合框搜索. [英] Combining first name field and last name field into fullname for combobox searching.

查看:112
本文介绍了将名字字段和姓氏字段组合为全名以进行组合框搜索.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一件简单的事情,我似乎还没弄清楚.

我想将名字和姓氏合并为一个全名字段,并将其用于组合框中的显示和导航.

我并不是真的想添加一个称为全名"的其他字段,但是如果这是我唯一的选择,那么我可以做到.

现在,我只精通Visual Basic,对于我当前的项目,我使用LINQ to Entities来处理数据.我目前还没有,也确实不打算在我的项目中使用存储过程.

我已经尝试过的是在实体数据模型的employees表中添加一个名为"FullName"的标量属性,但是我似乎无法像我所做的那样保存它的名字和姓氏字段之前使用常规数据集.我以为自从我使用实体以来,它就不会以这种方式工作.

任何帮助都感激不尽.再次感谢您抽出宝贵的时间阅读本文.

Just a simple thing I can''t really seem to figure out.

I want to combine the first and the last name into a single full name field and use it for display and navigation in a combo box.

I''m not really looking to add a whole other field called full name, but if that''s my only option then I can do it.

Right now, I''m only skilled in visual basic and for my current project I''m using LINQ to Entities for manipulating data. I have not and really do not plan to use stored procedures for my project at the moment.

What I have already tried, is to add a scalar property called "FullName" to my employees table in the entity data model, but I can''t seem to get it to hold the first and last name fields like I''ve done before with regular data sets. I''m assuming it won''t work this way since I''m using Entities.

Any help will be much appreciated. Thanks again for taking the time to read this.

推荐答案

将字段添加到数据模型中时,期望可以从数据库中检索该字段.但是,由于您没有此字段,因此不会将其添加到实体中.

为实体创建的类是局部类,因此您可以轻松地在项目中创建另一个局部类,并添加将名字和姓氏属性组合在一起的fullname属性.
When you add a field to the data model it is expected to be retrieved from the database. However, since you don''t have this field it won''t add it to the entity.

The class created for the entity is a partial class so you can easy create another partial class in the project and add the fullname property which combines the first and last name properties.


这篇关于将名字字段和姓氏字段组合为全名以进行组合框搜索.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆