日期:2014-05-17  浏览次数:20893 次

请问,Linq查询对应不同的字段,如何封装方法?求大神.
var person = from p in _LinqAddressBook.T_AddressBooks
                         where p.FName.Contains(txtSearchCondition.Text.Trim())
                         orderby p.FName ascending
                         select new {
                             编号 = p.FId,
                             姓名 = p.FName,
                             性别 = p.FSex,
                             电话号码 = p.FPhone,
                             QQ = p.Fqq,
                             国际电话号码 = p.FWordPhone,
                             EMail = p.FEMail,
                             手机号 = p.FHandSet
                         };
//我的数据库表字段我都列在这里了,我试过封装为,但是感觉好难弄.
//开始时我这样做:
void BindToDataGridView(string fieldVal) {
            var person = from p in _LinqAddressBook.T_AddressBooks
                         where fieldVal.Contains(txtSearchCondition.Text.Trim())
                         orderby fieldVal ascending