控制器:
[HttpDelete]
public ActionResult Delete(int id)
{
}
Run Code Online (Sandbox Code Playgroud)
方法:
ControllerBase controllerToLinkTo = string.IsNullOrEmpty(controllerName)
? htmlHelper.ViewContext.Controller
: GetControllerByName(htmlHelper, controllerName);
var controllerContext = new ControllerContext(htmlHelper.ViewContext.RequestContext, controllerToLinkTo);
var controllerDescriptor = new ReflectedControllerDescriptor(controllerToLinkTo.GetType());
ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(controllerContext, actionName);
Run Code Online (Sandbox Code Playgroud)
当操作具有[Delete]属性时,ActionDescriptor为null.有没有办法从控制器上下文获取操作名称?
如何根据情况使LINQ区分大小写并且不区分大小写?
我正在使用sql server 2008和Entity Framework 4.0.
我更改了COLLATION以使SQL Server区分大小写.所以对于这样的场景:
query = query.Where(x => x.Username == username);
Run Code Online (Sandbox Code Playgroud)
它很棒.但是,当按主题(或名称或类似)搜索时,我需要能够从db 忽略大小写中提取数据,如下所示:
query = query.Where(x => (x.Name.Contains(Name)));
Run Code Online (Sandbox Code Playgroud)
当记录是"TestString"并且我正在寻找"测试"或"测试"或类似时,它不起作用.我如何才能使它在文本中找到文本或字符串的一部分?谢谢
有一个简单的.net .exe应用程序.一旦执行它的生命周期是什么.我的理解是发生以下情况:
> 1. OS loads exe assemblies into memory
> 2. OS checks if it is in fact .net assembly
> 3. mscoree.dll loads, and loads CLR
> 4. CLR takes over and loads external dlls, GC stuff, memory management etc.
> 5. CLR creates app domain where exe assemblies are loaded
> 6. exe is started
Run Code Online (Sandbox Code Playgroud)
鉴于以上是正确的(请随意详细说明),我对CLR加载程序集时的最后一步感兴趣.
有了这个界面,我怎么能用moq模拟这个对象?
public interface IMyCollection : IEnumerable<IMyObject>
{
int Count { get; }
IMyObject this[int index] { get; }
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
无法将表达式IEnumerable转换为IMyCollection
给出像这样的json字符串:
[{"id":28,"Title":"Sweden"},{"id":56,"Title":"USA"},{"id":89,"Title":"England"}]
Run Code Online (Sandbox Code Playgroud)
我需要检查一个对象是否存在,检查所有字段,意思是:
{"id":28,"Title":"Sweden"} => exists
{"id":29,"Title":"Sweden"} => doesn't exist
Run Code Online (Sandbox Code Playgroud)
要么
{"id":28,"Title":"Sweden"} => exists
{"id":28,"Title":"Sweden2"} => doesn't exist
Run Code Online (Sandbox Code Playgroud)
集合可以包含任意数量的对象,对象将始终具有相同数量的属性(id,title)或(id,title,firstName)等.
另外,为了检查现有对象,是否需要将字符串解析为json对象集合?
我试过这个:
$.map(val, function (obj) {
if (obj === val)
alert('in');
return obj; // or return obj.name, whatever.
});
Run Code Online (Sandbox Code Playgroud) 我一直在阅读很多关于Docker及其用途的内容.目前,我们正在使用TFS构建和部署我们的内部应用程序(.net c#).过渡到Docker有什么好处吗?设置的意义是在TFS运行构建之后,它将部署到容器中吗?
目前除了做一堆手动步骤之外,没有简单的方法来运行构建:如何:在桌面上构建团队项目.
对于以下内容:
<div class="section">
<div class="row infoOn">
<div class="itemWrap clearfix">
<div class="itemTop clearfix">
</div>
<label class="">File title:</label>
<div class="inputWrap clearfix">
<input type="text" class="text inpButton" value="upload file first" disabled="true"/>
<a id="fileUpload" href="#" class="button">Browse</a>
</div>
</div>
</div>
<!-- filelist -->
<div class="row uploadList">
<div class="itemWrap clearfix">
<label> </label>
<div class="inputWrap clearfix" style="position:relative;">
<ul>
<li><span class="qq-upload-file">companyPic.png</span><span class="qq-upload-spinner"></span><span class="qq-upload-size" style="display: none;"></span><a href="#" class="qq-upload-cancel">Cancel</a><span class="qq-upload-failed-text">Failed</span></li>
<li><span class="qq-upload-file">companyPic.png</span><span class="qq-upload-spinner"></span><span class="qq-upload-size" style="display: none;"></span><a href="#" class="qq-upload-cancel">Cancel</a><span class="qq-upload-failed-text">Failed</span></li>
<li><span class="qq-upload-file">untitled.bmp</span><span class="qq-upload-spinner"></span><span class="qq-upload-size" style="display: none;"></span><a href="#" class="qq-upload-cancel">Cancel</a><span class="qq-upload-failed-text">Failed</span></li>
<li><span class="qq-upload-file">This i...Document.docx</span><span class="qq-upload-spinner"></span><span …Run Code Online (Sandbox Code Playgroud) 我有以下内容:
<!-- group clone //-->
<div class="section">
<div class="parent row infoOn">
<div class="validGroup">
<a title="remove" class="iconClose" href="#">remove</a>
<div class="grouping">
<div class="clearfix valid">
<label>Name<span class="iconReq"> </span>:</label>
<input type="password" class="text inpButton" name="items[0].first">
</div>
<div class="clearfix">
<label>Email<span class="iconReq"> </span>:</label>
<input type="text" class="text inpButton" name="items[0].first">
</div>
</div>
</div>
</div>
<div class="row addControl">
<a href="#" class="button">Add</a>
</div>
</div>
<!-- group clone //-->
Run Code Online (Sandbox Code Playgroud)
和jQuery:
$(function(){
// Control clone
$('div.addControl a.button').click(function (e){
e.preventDefault();
var parent = $(this).closest('.section').find('.parent:last');
var parentInput = parent.clone();
parentInput.find("input").val("");
parent.after(parentInput);
});
$('div.validGroup a.iconClose').live('click', function (e){
e.preventDefault(); …Run Code Online (Sandbox Code Playgroud) 如何为查询字符串添加值?
我正在尝试这样做:
String currurl = HttpContext.Current.Request.RawUrl;
var querystring = HttpContext.Current.Request.QueryString.ToString();
var PrintURL = currurl + (String.IsNullOrEmpty(querystring)) ?
HttpContext.Current.Request.QueryString.Add("print", "y") : string.Empty;
Run Code Online (Sandbox Code Playgroud)
但我一直收到这个错误:
无法将类型'string'隐式转换为'bool'
我要做的就是获取当前网址并将"pring = y"添加到查询字符串
我正在尝试检查(在.net c#中)我是否能够连接到SQL服务器.但是每当我在连接字符串中指定实例时,我就无法再连接了.:
这有效:
builder.ConnectionString = "Server=DLS-534;user id=sa;password=Mypassword;initial catalog=master";
Run Code Online (Sandbox Code Playgroud)
这不起作用:
builder.ConnectionString = "Server=DLS-534\\SQL_2008_R2_DEV;user id=sa;password=Mypassword;initial catalog=master";
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?我确实需要能够连接到特定的实例,因为用户可能有几个dbs.
我的完整代码:
SqlConnectionStringBuilder builder =
new SqlConnectionStringBuilder();
builder.ConnectionString = "Server=DLS-534\\SQL_2008_R2_DEV;user id=sa;password=Mypassword;initial catalog=master";
using (var connection = new SqlConnection(builder.ConnectionString))
{
try
{
connection.Open();
return true;
}
catch (SqlException)
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net ×3
jquery ×3
.net ×2
javascript ×2
sql ×2
asp.net-mvc ×1
boot2docker ×1
build-server ×1
c#-4.0 ×1
docker ×1
linq ×1
moq ×1
sql-server ×1
tfs ×1
unit-testing ×1