小编Sno*_*ogg的帖子

.NET使用块和返回; 关键词

当我说这个

using (Entities db = new Entities())
{
    return db.TableName.AsQueryable().ToList();
}
Run Code Online (Sandbox Code Playgroud)

我是否绕过了使用块的功能,因为我返回了一些内容,并且该方法在退出using块之前退出,因此我认为using块不会用于其目的并处置资源.

它是否正确?

.net using-statement

10
推荐指数
1
解决办法
1118
查看次数

使SQL多次选择同一行

我需要测试我的邮件服务器.如何制作一个Select语句,选择说ID = 5469一千次.

sql select

9
推荐指数
3
解决办法
5万
查看次数

LINQ 2 Entities,如何在linq查询中检查DateTime.HasValue

我有这种方法应该从称为ENTRY的表(&EntitySet)中获取最新消息的发布

///方法获取“天”作为参数,用于新的TimeSpan(days,0,0,0); !!

using (Entities db = new Entities())
    {
        var entries = from ent in db.ENTRY
                      where ent.DATECREATE.Value > DateTime.Today.Subtract(new TimeSpan(days, 0, 0, 0))
                      select new ForumEntryGridView()
                      {
                          id = ent.id,
                          baslik = ent.header,
                          tarih = ent.entrydate.Value,
                          membername = ent.Member.ToString()
                      };
        return entries.ToList<ForumEntryGridView>();
    }
Run Code Online (Sandbox Code Playgroud)

在这里,DATECREATED在数据库中为空。我无法在此查询中放置“如果” ...以任何方式进行检查?提前Thx

c# linq-to-entities nullable

4
推荐指数
2
解决办法
3876
查看次数

标签 统计

.net ×1

c# ×1

linq-to-entities ×1

nullable ×1

select ×1

sql ×1

using-statement ×1