我有一个应用程序在几乎所有表中使用GUID作为主键,我已经读过使用GUID作为主键时存在性能问题.老实说,我没有看到任何问题,但我即将开始一个新的应用程序,我仍然想使用GUID作为主键,但我想使用复合主键(GUID和可能是另一个字段) .)
我正在使用GUID,因为当您拥有不同的环境(如"生产","测试"和"开发"数据库)以及数据库之间的迁移数据时,它们很好并且易于管理.
我将使用Entity Framework 4.3,我想在将其插入数据库之前在应用程序代码中分配Guid.(即我不想让SQL生成Guid).
创建基于GUID的主键的最佳做法是什么,以避免与此方法相关的假设性能命中?
sql-server database-design entity-framework guid primary-key
我有一个查询,我得到一个日期的WeekDay但默认情况下:
星期日= 1
Moday = 2
等等
功能是:
DATEPART(dw,ads.date) as weekday
Run Code Online (Sandbox Code Playgroud)
我需要结果:
星期天= 7
星期一= 1
等等
这样做有什么捷径吗?或者我必须做一个CASE statement
?
我已经为Bootstrap输入实现了一个jQuery自动完成功能.jQuery自动完成工作正常,但我希望将结果看作组合,我猜它现在正在发生,因为我正在使用BootStrap.
这是我正在分配自动完成的字段:
<div class="form-group">
<label>Employee</label>
<input class="form-control" name="txtEmployee" placeholder="Trabajador">
</div>
Run Code Online (Sandbox Code Playgroud)
$(this).autocomplete({
source: function(request, response) {
$.ajax({
url: '@Url.Content("~/Employee/SearchEmployee")/',
type: 'POST',
contentType: 'application/json',
dataType: "json",
data: JSON.stringify({
employerId: 1,
searchStr: me.val()
}),
success: function(data) {
if (data.success) {
response($.map(data.data, function(item) {
return {
label: "(" + item.EmployeeNumber + ") " +
item.FirstName + " " +
item.MothersLast + ", " +
item.FathersLast,
employeeId: item.EmployeeId
}
}));
}
}
});
},
minLength: 3
});
Run Code Online (Sandbox Code Playgroud)
结果显示但是像这样:
如何使用Bootstrap设置结果样式,以便我可以看到它们如dropdownlist?
我想知道是否有办法将24小时时间格式的字符串转换为TimeSpan.
现在我有一个"旧时尚风格":
string stringTime = "07:35";
string[] values = stringTime.Split(':');
TimeSpan ts = new TimeSpan(values[0], values[1], 0);
Run Code Online (Sandbox Code Playgroud) 我有一个Web API项目,我的方法总是返回HttpResponseMessage.
所以,如果它工作或失败我返回:
没有错误:
return Request.CreateResponse(HttpStatusCode.OK,"File was processed.");
Run Code Online (Sandbox Code Playgroud)
任何错误或失败
return Request.CreateResponse(HttpStatusCode.NoContent, "The file has no content or rows to process.");
Run Code Online (Sandbox Code Playgroud)
当我返回一个对象然后我使用:
return Request.CreateResponse(HttpStatusCode.OK, user);
Run Code Online (Sandbox Code Playgroud)
我想知道如何向HTML5客户端返回更好的封装respose,以便我可以返回有关事务的更多信息等.
我正在考虑创建一个可以封装HttpResponseMessage但也有更多数据的自定义类.
有没有人实现类似的东西?
我需要获取触发过滤器属性的控制器.
我有以下过滤器:
public override void OnException(HttpActionExecutedContext filterContext) {
if (filterContext == null) {
throw new ArgumentNullException("filterContext");
}
if (filterContext.Exception != null) {
// string controllerName = (string) filterContext.....??
// string actionName = (string) filterContext.....?
HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.InternalServerError) {
Content = new StringContent("An unhandled exception was thrown by Customer Web API controller."),
ReasonPhrase = "An unhandled exception was thrown by Customer Web API controller."
};
filterContext.Response = msg;
}
}
Run Code Online (Sandbox Code Playgroud)
在传统的MVC中,这很简单:
string controllerName = (string) filterContext.RouteData.Values["controller"];
string actionName = …
Run Code Online (Sandbox Code Playgroud) 我在Amazon S3存储桶中有关键数据.我想每周将其他内容备份到另一个云服务,甚至是S3内部.如果数据丢失,最好的方法是将我的存储桶同步到不同区域内的新存储桶.
我怎样才能做到这一点?
我有一个简单的网站,它实现了jQuery,以便在Index.html顶部横幅中创建一些带有一些图像的Slider.
现在,我想使用AngularJS,所以我将HTML代码分解为单独的部分.
如果我在原始版本中运行Index.html(不应用AngularJS模式),那么我可以看到滑块工作正常.
在应用AngularJS模式时,我将顶部横幅HTML移动到部分html,然后将ng-view应用于顶部横幅最初所在的div.
var app = angular.module('website', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider.
when('/about',{templateUrl:'app/partials/about.html'}).
when('/contact',{templateUrl:'app/partials/contact.html'}).
otherwise({redirectTo:'/home',templateUrl:'app/partials/home.html'})
});
Run Code Online (Sandbox Code Playgroud)
当我刷新页面滑块不工作时,渲染为简单的html没有任何jQuery效果,真是一团糟.
这个部分有一些jQuery插件,通常由document.ready激活.但是当角度载荷部分在ng视图中时,此事件不会触发.如何调用此事件来初始化jQuery插件?
有任何线索如何解决这个问题?
感谢任何帮助.
我有两张SQL Server
桌子:
invoice
)invoice_relation
)invoice
table存储具有事务作品集的所有发票记录.
invoice_relation
表存储发票之间的任何关系.
这是发票如何相互关联的示例:
所以,我们的目标是找到" folio
"下invoice
表中给出的invoicenumber
和folio
,但folio
有时不会是folio
了invoice
了,所以我需要做的,为了所有的树关系的搜索找到,如果任何发票匹配发票号码但也是folio
这种关系的一部分.
例如,我必须找到对开的发票编号:
在我的查询中,我需要首先通过作品集找到因为它是我的invoice
表主键.然后,将尝试匹配A1122
与D1122
该会不匹配,所以后来我搜索所有树结构发现,如果有一个A1122
.结果将是A1122
在对开页中找到发票1000
.
有关如何做到这一点的任何线索?
这是一个如何使用数据创建上述示例表的脚本:
CREATE TABLE [dbo].[invoice](
[folio] [int] NOT NULL,
[invoicenumber] [nvarchar](20) NOT NULL,
[isactive] [bit] NOT NULL,
CONSTRAINT [PK_invoice] PRIMARY KEY CLUSTERED
(
[folio] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, …
Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET MVC 4应用程序,我想实现工作单元模式.
在我的Web项目中,我有:
IocConfig.cs
using System.Web.Http;
using NinjectMVC.Data;
using NinjectMVC.Data.Contracts;
using Ninject;
namespace NinjectMVC
{
public class IocConfig
{
public static void RegisterIoc(HttpConfiguration config)
{
var kernel = new StandardKernel(); // Ninject IoC
// These registrations are "per instance request".
// See http://blog.bobcravens.com/2010/03/ninject-life-cycle-management-or-scoping/
kernel.Bind<RepositoryFactories>().To<RepositoryFactories>()
.InSingletonScope();
kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>();
kernel.Bind<INinjectMVCUow>().To<NinjectMVCUow>();
// Tell WebApi how to use our Ninject IoC
config.DependencyResolver = new NinjectDependencyResolver(kernel);
}
}
}
Run Code Online (Sandbox Code Playgroud)
Global.asax中
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using …
Run Code Online (Sandbox Code Playgroud) c# ×3
sql-server ×3
asp.net-mvc ×2
jquery ×2
sql ×2
amazon-s3 ×1
angularjs ×1
backup ×1
guid ×1
httpresponse ×1
json ×1
ninject ×1
primary-key ×1
timespan ×1
unit-of-work ×1