如何搜索两个组合字段.如果可能,搜索应该在SQL端进行.
所以说我有一个名字和姓氏的客户表.我希望用户能够使用一个搜索框搜索这两列.
我的查询目前看起来像这样:
var query = DbContext.Customers
.Where(c => c.FirstName.Contains(search) || c.LastName.Contains(search));
Run Code Online (Sandbox Code Playgroud)
但它应该是这样的
var query = DbContext.Customers
.Where(c => c.FullName.Contains(search));
Run Code Online (Sandbox Code Playgroud) 我在excel中有以下数据:
a, b, c
d
e
f, g
h
i
Run Code Online (Sandbox Code Playgroud)
每行代表一行和一个单元格.
我想将其转换为:
a
b
c
d
e
f
g
h
i
Run Code Online (Sandbox Code Playgroud)
我正在使用以下宏,但我不能让自动调整大小来执行插入,而不是覆盖单元格值.任何帮助表示赞赏.
Sub SplitCells()
Dim i As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For i = 1 To Selection.Rows.Count
Dim splitValues As Variant
splitValues = split(Selection.Rows(i).Value, ",")
Selection.Rows(i).Resize(UBound(splitValues) - LBound(splitValues) + 1).Value = Application.Transpose(splitValues)
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2012中有一个数据库项目.我正在尝试创建一个MSBuild项目来在构建服务器上发布数据库.在我的解决方案中,我有一个发布配置文件,我想在构建服务器上使用.
我有以下目标设置:
<Target Name="BuildDatabases">
<MSBuild Projects="$(DBProjectPath)" Targets="Build;Deploy" Properties="DeployOnBuild=true;SqlPublishProfilePath=BuildServer.publish">
</MSBuild>
</Target>
Run Code Online (Sandbox Code Playgroud)
我尝试过PublishProfile和SqlPublishProfilePath的组合无济于事.我总是收到:
Deploy Error: The connection string is not valid
Run Code Online (Sandbox Code Playgroud)
我可以使用VS内部的发布配置文件,没有连接问题.
MVC 3 RTM.拥有一个具有AllowHtml属性的模型.在我的控制器操作中,如果操作将FormCollection作为参数,则会抛出异常:
[HttpPost]
public ActionResult Edit(FormCollection collection, int id)
{
var myEntity = _myRepo.Get(id);
TryUpdateModel(myEntity);
return DoSave(myEntity);
}
Run Code Online (Sandbox Code Playgroud)
从客户端检测到潜在危险的Request.Form值
但是,如果我的控制器操作使用对象而不是FormCollection,则它不会抛出异常.
[HttpPost]
public ActionResult Edit(MyEntity postedEntity, int id)
{
var myEntity = _myRepo.Get(id);
TryUpdateModel(myEntity);
return DoSave(myEntity);
}
Run Code Online (Sandbox Code Playgroud)
我已经设置好了
httpRuntime requestValidationMode ="2.0"
使用FormCollection时为什么会失败?
在MVC 3应用程序中将Entity Framework 4与Ninject一起使用时,存储库和EF上下文的相应LifeCycle Scope是什么?
我一直在使用默认的InTransientScope,但质疑它是否应该是InRequestScope.
public class MyController: Controller
{
private readonly IMyRepo _repo;
public MyController(IMyRepo repo)
{
_repo = repo;
}
public ActionResult Index()
{
var results = _repo.GetStuff();
return View(results);
}
}
Run Code Online (Sandbox Code Playgroud)
Ninject模块:
public class MyServices : NinjectModule
{
public overrride void Load()
{
Bind<IMyRepo>.To<MyRepo>();
Bind<MyContext>.ToSelf();
}
}
Run Code Online (Sandbox Code Playgroud)
MyRepo:
public class MyRepo: IMyRepo
{
private readonly MyContext _context;
public MyRepo(MyContext context)
{
_context = context;
}
public IEnumerable GetStuff()
{
return _context.Entity;//query stuff
}
}
Run Code Online (Sandbox Code Playgroud) 使用基于属性的路由我想匹配以下路由:
~/ ~/Home ~/Home/Index
到HomeController.Index,这条路线:
~/Home/Error
到HomeController.Error.这是我的配置:
[Route("[controller]/[action]")]
public class HomeController : Controller {
[HttpGet, Route(""), Route("~/")]
public IActionResult Index() {
return View();
}
[HttpGet]
public IActionResult Error() {
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
我试过添加Route("[action]"),Route("Index")和其他组合,但仍然没有得到匹配:
/Home/Index
c# asp.net-core-mvc asp.net-core asp.net-core-routing asp.net-core-mvc-2.0
我正在研究生成随机人类友好代码的方法,但不能(容易)猜测.这将用于赠送奖品(想想独特的折扣代码).我们要产生大约50k.有没有标准的方法/算法来实现这一目标?我正在考虑使用GUID并应用CRC.这是一个坏主意吗?
如果重要,请使用.netframework 3.5.
我正在使用MVC 3 w/Razor并使用新的动态ViewBag属性.我想将ViewBag属性与EditorFor/LabelFor Html助手一起使用,但无法弄清楚语法.
View确实有@model设置,但我尝试使用的对象不是该模型的一部分.我知道我可以创建一个ViewModel,但这不是我想要的.
有人可以帮忙吗?
控制器:
var myModel= _repo.GetModel(id);
var newComment = new Comment();
ViewBag.NewComment = newComment;
return View(myModel);
Run Code Online (Sandbox Code Playgroud)
视图:
@model Models.MyModel
@(Html.EditorFor(ViewBag.NewComment.Comment))
Run Code Online (Sandbox Code Playgroud) 如果有人问过这个道歉...但我找不到(或者我使用完全错误的条款......)
我有一个这样的表格:
<form>
<div>
<input name="[0].RoleId" type="hidden" value="1">
<input name="[0].RoleName" type="hidden" value="Administrator">
<input name="[0].Selected" type="checkbox" checked="checked" >
<span>Administrator</span>
</div>
<div>
<input name="[1].RoleId" type="hidden" value="2">
<input name="[1].RoleName" type="hidden" value="Manager">
<input name="[1].Selected" type="checkbox" >
<span>Manager</span>
</div>
etc...
</form>
Run Code Online (Sandbox Code Playgroud)
我想将其转换为以下json:
roles [
{
"RoleId" : "1",
"RoleName" : "Administrator",
"Selected" : "checked"
},
{
"RoleId" : "2",
"RoleName" : "Manager",
"Selected" : "unchecked"
}
]
Run Code Online (Sandbox Code Playgroud)
我正在使用ASP.Net MVC 3来生成输入元素.基本上我要做的是以下......
我有一个用户屏幕.用户可以从那里选择角色列表(在jquery ui对话框中显示).当用户选择角色并单击"确定"时,弹出窗口将关闭,他们将在用户屏幕中看到所选角色.我打算使用jquery数据来存储在对话框中选择的数据,然后我需要解析并添加到用户屏幕.这是所有客户端,直到他们在用户屏幕中单击"保存".
在WinJS中,我可以在listView中绑定属性getter吗?假设我有一个像这样定义的对象:
var MyLib = MyLib || {};
MyLib.ToDoItem = function() {
this.name = '';
this.description = '';
Object.defineProperty(this, "completed", {
get : function() {
return false;
}
});
}
MyLib.ToDoList = [];
//MyLib.ToDoList.push....add todo items
Run Code Online (Sandbox Code Playgroud)
我声明一个WinJS.Binding.Template,其中所有属性都绑定,除了使用属性getter定义的属性:
<div id="myItemTemplate" data-win-control="WinJS.Binding.Template">
<div class="titleTile">
<h4 class="item-title" data-win-bind="textContent: name"></h4>
<p data-win-bind="textContent: description"></p>
<div data-win-bind="textContent: completed"></div> <-- Renders as undefined
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
"已完成"属性呈现为未定义.如果我在我正在加载数据的javascript控制台中放置一个断点,我可以进入已完成的属性,但数据绑定似乎不喜欢它...任何想法?