工作之杂记--first linq
来源:互联网 发布:淘宝图片轮播怎么更换 编辑:程序博客网 时间:2024/05/29 11:58
使用linq:查询赋予自定义对象
string _eventName = Request["Content"] ?? ""; var _userComment = from com in db.UserComment join users in db.User on com.UserID equals users.Id //join hd in db.table1 on com.EventID equals hd.ID //where hd.HuoDongName.Contains(_eventName) select new UserComments { ID = com.ID, EventID = com.EventID, UserID = com.UserID, EventContent = com.EventContent, UpQty = com.UpQty, DownQty = com.DownQty, InDateTime = com.InDateTime, UserName = users.UserName//,hd.HuoDongName }; List<UserComments> comm = _userComment.ToList();
注意点:自定义对象一定要有构造函数 如下
public class UserComments { public int ID { get; set; } public int Event { get; set; } //..... public UserComments(int Id, int eventID) { this.ID = Id; this.Event = eventID; } }
go on
var _even = from hd in db.table1 orderby hd.ID descending select new NameValue { Value = hd.ID, Name = hd.HuoDongName }; huoDongList = _even.ToList(); var _user = from user in User where user.Status==1 select new NameValue { Value = user.Id, Name = user.NickName }; userList = _user.ToList();
0 0
- 工作之杂记--first linq
- 工作之杂记--JS杂记
- 工作之杂记--缓存操作
- 工作之杂记--use jQueryUI
- linq语法之Where First、FirstOrDefault Single...
- 《工作杂记》之phoronix-test-suite
- 工作杂记
- 工作杂记
- 工作杂记
- 工作杂记
- 工作杂记
- 工作杂记
- 工作杂记
- Linq 杂记(读书笔记)
- 工作之杂记-wmi start service 核心代码
- 26.odoo入门——工作杂记之many2one
- 杂记--关于工作
- SQL工作杂记
- POJ 2155 树套树—线段树套线段树
- cocos2d-html5如何运行
- 【Leetcode】Length of Last Word
- iOS Objective-C Block 的使用示例
- fastDB使用过程中遇到的几个问题
- 工作之杂记--first linq
- 测试中“特殊数据”提出的挑战
- 拷贝构造函数和赋值函数
- easyui window tool 弹出窗口 工具栏 重用问题
- jsp绝对路径相对路径
- android 修改状态栏和标题栏颜色
- 聪明的质监员 2011年NOIP全国联赛提高组
- sql
- 多媒体广告机玩转信息!