我有一个从视图中填充的大表.这样做是因为视图需要很长时间才能运行,并且更容易在表中提供数据.每隔一段时间运行一个过程以更新表.
TRUNCATE TABLE LargeTable
INSERT INTO LargeTable
SELECT *
FROM viewLargeView
WITH (HOLDLOCK)
Run Code Online (Sandbox Code Playgroud)
我想在插入时锁定这个表,所以如果有人试图选择一个他们在截断后不会收到的记录.我正在使用的锁似乎锁定视图而不是表.
有没有更好的方法来解决这个问题?
是否有可能连接到Web上的SQL Server数据库并在那里创建一些表查询等用于测试目的?
当您不想安装SQL Server(例如,您在另一个操作系统上)但仍然对此技术感兴趣时,这将非常有用.如果有可能连接到以编程方式创建的数据库,那将会很棒.
我在MVC3项目中从表单调用JS方法时遇到问题:我有一个"搜索"页面没有带两个按钮的表单 - 搜索和取消.点击搜索在ProductDefinition中运行JS函数runSearch.
<div id="productSearch-dialog" class="modal fade" style="width: 1000px; display: none">
<div class="modal-header">
<button class="close" aria-hidden="true" data-dismiss="modal" type="button">×</button>
<h3>Search Results</h3>
</div>
<div class="modal-body" style="height: 650px;">
<div>
<input id="inputname" type="text" /><font class="red-font" id="lblrequired" style="display: none">*</font>
</div>
<div id="searchresultcontain" class="grid">
</div>
<div id="Pagination" class="pagination">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="productDefinition.runSearch();">Search</button>
<button class="btn btn-primary" data-dismiss="modal">Cancel</button>
</div>
Run Code Online (Sandbox Code Playgroud)
当我按下时如何运行这个JS方法(runSearch)?据我所知,这将是onsubmit事件,它是form事件,所以我需要添加带有onsubmit属性的表单元素.我用BeginForm帮助器方法尝试了周围的输入字段:
@using (Html.BeginForm(new { onsubmit = "productDefinition.runSearch();" }))
{
<input id="inputname" type="text" /><font class="red-font" id="lblrequired" style="display: none">*</font>
<input type="submit" value="Submit" style="visibility: hidden" />
}
Run Code Online (Sandbox Code Playgroud)
但它似乎没有工作 …
我无法在C#中的保留关键字列表中找到"by",但Resharper Visual Studio插件似乎认为它是一个 - 只要它生成代码(例如通过执行重构命令),就会使用@ escape预先设置它
将哈希内部转换成最优雅的方法是什么?
我的意思是用值替换键,反之亦然(假设所有值都是100%唯一的).
例如
从...开始
my %start = (1=>"a", 2=>"b", 3=>"c");
# ...
# PROFIT:
my %finish = ("c" => 3, "b" => 2, "a" => 1);
Run Code Online (Sandbox Code Playgroud)
我知道我可以用蛮力的方式做到这一点:
foreach my $key (keys %start) {
my $value = $start{$key};
$finish{ $value } = $key;
}
Run Code Online (Sandbox Code Playgroud)
但这不是最优雅的方式!
我在.cshtml中的操作链接是这样的:
@Html.ActionLink("Reply", "Post_Reply", new { item.ID, item.Post_ID, item.Reply_ID })
Run Code Online (Sandbox Code Playgroud)
我在控制器中的方法是这样的:
[Authorize]
public ActionResult Post_Reply(int PostId=0, int Id = 0, int ReplyId = 0)
{
post posts = new post();
posts.ID = Id;
return View(posts);
}
Run Code Online (Sandbox Code Playgroud)
但只有item.ID的值被传递,其他两个值item.Post_ID和item.Reply_ID没有被传递..任何人都可以指导我..谢谢..
我正在尝试在我的c#应用程序中添加新的静态端口映射.因为我的应用程序作为服务器运行,我希望它在端口8000上监听.
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(8000, "TCP", 8000, "192.168.1.100", true, "Local Web Server");
Run Code Online (Sandbox Code Playgroud)
但它不起作用!,例外情况如下:
你调用的对象是空的.
有人能帮帮我吗?
这就是我正在做的:http://pietschsoft.com/post/2009/02/05/NET-Framework-Communicate-through-NAT-Router-via-UPnP.aspx
我在我的sql数据库上设置了临时用户帐户,其中存储了我的网站用户的用户名,密码和添加日期.
我最初将以编程方式删除这些记录,但现在我想知道sql server 2008是否有内置函数,允许记录在让我们说一天后自动删除.
这将解决用户在临时帐户关闭后能够保持登录系统的问题
谢谢
我试图解析格式的日期:
2013-09-17T05:15:27.947
这是我的代码
String MessageRecieptDate = messageReceiptDate.Replace("T", " ").Remove(messageReceiptDate.Length-4);
DateTime dt = new DateTime();
IFormatProvider culture = new CultureInfo("en-US");
dt = DateTime.ParseExact(MessageRecieptDate, "dd MMM", culture);
Run Code Online (Sandbox Code Playgroud)
但它每次都会给出一些格式异常.似乎我错过了一些基本的东西.
我有以下函数,其中应该返回 IEnumerable 类型?如何将列表转换为 IEnumerable?并返回一个空的 IEnumerable?
public IEnumerable<SoftwareImageTestPlan> GetAssignedTestPlansForSPSI(int SoftwareProductID, int SoftwareImageID)
{
var records = _entities.tblSoftwareImageTestPlans
.Where(x => x.SoftwareProductID == SoftwareProductID && x.SoftwareImageID == SoftwareImageID)
.ToList();
if (records == null)
return new List<SoftwareImageTestPlan>();
else
return records;
}
Run Code Online (Sandbox Code Playgroud)
错误:
无法将类型“System.Collections.Generic.List<....> 隐式转换为 System.Collections.Generic.IEnumerable<.....>。存在显式转换(您是否缺少演员表?)
c# ×7
.net ×5
sql ×3
sql-server ×3
asp.net-mvc ×2
database ×2
asp.net ×1
datetime ×1
hash ×1
html ×1
html-helper ×1
ienumerable ×1
javascript ×1
linq ×1
locking ×1
networking ×1
parsing ×1
perl ×1
t-sql ×1
upnp ×1