小编DRo*_*rtE的帖子

Visual Studio 2013数据库项目删除列

当数据表中存在数据行时,是否有人知道从数据库中删除现有列的最佳方法.

我试过的似乎并不想工作.我在数据库项目中包含了一个预部署脚本

GO
if exists(select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'Mercury.dbo.Discounts' and COLUMN_NAME = 'ColumnToRemove')
BEGIN
    ALTER TABLE Database.dbo.Table1 Drop Column ColumnToRemove
END
GO
Run Code Online (Sandbox Code Playgroud)

然后在首先创建表的脚本中,我从Create Table Script中删除了有问题的列

当执行dacpac时,我得到以下内容

Initializing deployment (Start)
*** The column [dbo].[Table1].[ColumnToRemove] is being dropped, data loss could occur.
Initializing deployment (Complete)
Analyzing deployment plan (Start)
Analyzing deployment plan (Complete)
Updating database (Start)
An error occurred while the batch was being executed.
Updating database (Failed)
*** Could not deploy package.
Warning SQL72015: The column [dbo].[Table1].[ColumnToRemove] is …
Run Code Online (Sandbox Code Playgroud)

database-project visual-studio-2013

36
推荐指数
3
解决办法
2万
查看次数

Chrome开发者工具响应/预览标签"漂亮打印"或"格式化"

有没有人知道chrome开发人员工具的工具或扩展,它将接受请求的响应并将其格式化为XML或JSON.我已经做了很多寻找,并且无法找到任何类型的工具来正确格式化响应选项卡给出xml或json响应文本.

在此输入图像描述

xml json google-chrome

31
推荐指数
2
解决办法
2万
查看次数

如何在Resharper 8中获得多行TODO

我试图弄清楚如何将选项中的正则表达式 - >重新合并中的待办事项更改为颜色代码,并允许在待办事项中使用多行.

有任何想法吗?

resharper

15
推荐指数
1
解决办法
1232
查看次数

RegExp构造函数和Regex文字测试函数之间的区别?

我对这怎么可能感到困惑......

var matcher = new RegExp("d", "gi");
matcher.test(item)
Run Code Online (Sandbox Code Playgroud)

上面的代码包含以下值

item = "Douglas Enas"
matcher = /d/gi
Run Code Online (Sandbox Code Playgroud)

然而,当我连续运行matcher.test函数时,第一次运行得到true,第二次运行得到false.

matcher.test(item) // true
matcher.test(item) // false
Run Code Online (Sandbox Code Playgroud)

如果我使用regexp文字,如

/d/gi.test("Douglas Enas") 
Run Code Online (Sandbox Code Playgroud)

然后用铬背靠背运行我两次都是真的.对此有解释吗?

在chrome控制台中背对背运行的示例使用构造函数创建正则表达式对象

matcher = new RegExp("d","gi")
/d/gi

matcher.test("Douglas Enas")
true

matcher.test("Douglas Enas")
false

matcher
/d/gi
Run Code Online (Sandbox Code Playgroud)

示例使用文字的背靠背调用

/d/gi.test("Douglas Enas")
true

/d/gi.test("Douglas Enas")
true
Run Code Online (Sandbox Code Playgroud)

这个问题的原因是因为使用RegExp构造函数和测试函数对我失去匹配的值列表...但是使用文字我得到了我期望的所有值

UPDATE

                        var suggestions = [];

                        ////process response  
                        $.each(responseData, function (i, val)
                        {
                            suggestions.push(val.desc);
                        });


                        var arr = $.grep(suggestions, function(item) {
                            var matcher = new RegExp("d", "gi");
                            return matcher.test(item);
                        });
Run Code Online (Sandbox Code Playgroud)

在闭包内移动匹配器的创建包括缺少的结果."d"实际上是一个动态创建的字符串,但为简单起见,我使用了"d".我仍然不确定现在每次进行测试时都会创建一个新的表达式,当我迭代建议数组时会无意中排除结果仍然有点令人困惑,并且可能与匹配测试的进展有关

javascript regex

8
推荐指数
1
解决办法
2183
查看次数

复杂对象/嵌套映射中的自动映射和映射列表

我有一段时间从旧的映射标准转换为automapper.

这是我的课程

// Models
public class BaseModel
{
    public Int64 Id { get; set; }
    public Guid UniqueId { get; set; }
    public DateTime? CreateDate { get; set; }
    public DateTime? LastUpdate { get; set; }
} 

public class LibraryItemModel : BaseModel
{
    public string Name { get; set; }
    public string Description { get; set; }
    public string URL { get; set; }
    public bool IsActive { get; set; }
    public List<LibraryCategoryModel> Categories { get; set; }
}   

public …
Run Code Online (Sandbox Code Playgroud)

c# automapper-3

8
推荐指数
1
解决办法
2万
查看次数

你可以将一个匿名对象作为json发布到webapi方法,它是否将json对象的属性与webapi调用的参数相匹配?

我可以使用webapi方法吗?

[Route("someroute")]
public void SomeMethod(string variable1, int variable2, Guid variable3)
{
     //... Code here
}
Run Code Online (Sandbox Code Playgroud)

简单的json

var jsonvariable = new {
    variable1:"somestring",
    variable2:3,
    variable3: {9E57402D-8EF8-45DE-B981-B8EC201D3D8E}
}
Run Code Online (Sandbox Code Playgroud)

然后发帖子

HttpClient client = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings["SomeURL"]) };
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.PostAsJsonAsync("someroute", jsonvariable ).Result
Run Code Online (Sandbox Code Playgroud)

来自javascript我可以做这样的事情,它解决了各个属性,但我似乎无法用C#调用

var postData = {
     appUniqueId: appUniqueId
};

$http
   .post('someurl', postData)
   .success(function(response) {
      defer.resolve(response.data);
   });

webapi method
SomeWebMethod(Guid appUniqueId) <-- same name as in postdata
Run Code Online (Sandbox Code Playgroud)

c# json anonymous-types asp.net-web-api asp.net-web-api2

5
推荐指数
1
解决办法
5526
查看次数

使用Git时在Visual Studio 2013中设置Beyond Compare 4

我正在试图弄清楚如何配置BEYOND COMPARE 4以与Visual Studio 2013和GIT一起使用.无论我怎么配置它,它都想使用VS2013内部差异/合并工具.

超越比较安装目录

C:\Program Files (x86)\Beyond Compare 4
Run Code Online (Sandbox Code Playgroud)

来自git bash窗口

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\me>git --version
git version 1.8.3.msysgit.0

C:\Users\me>git config --list
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
rebase.autosquash=true
diff.tool=bc4
difftool.bc4.path=C:\Program Files (x86)\Beyond Compare 4\BComp.exe
merge.tool=bc4
mergetool.bc4.path=C:\Program Files (x86)\Beyond Compare 4\BComp.exe
core.editor="C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor
core.autocrlf=true
credential.helper=!\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/
git-credential-winstore.exe\"
user.name=me
user.email=me@email.com
gui.recentrepo=C:/DevSource/mercury

C:\Users\me>
Run Code Online (Sandbox Code Playgroud)

GIT中的全局gitcoinfig安装/ etc目录

[core]
    symlinks = false
    autocrlf = true
[color]
    diff …
Run Code Online (Sandbox Code Playgroud)

git beyondcompare visual-studio-2013

3
推荐指数
1
解决办法
1656
查看次数

Convert.ChangeType从int转换为bool

如果需要,使用以下命令从查询字符串中获取值并转换为特定类型.

public static T Convert<T>(NameValueCollection QueryString, string KeyName, T DefaultValue) where T : IConvertible
    {
        //Get the attribute
        string KeyValue = QueryString[KeyName];

        //Not exists?
        if (KeyValue == null) return DefaultValue;

        //Empty?
        if (KeyValue == "") return DefaultValue;

        //Convert
        try
        {
            return (T)System.Convert.ChangeType(KeyValue, typeof(T));
        }
        catch
        {
            return DefaultValue;
        }
    } 
Run Code Online (Sandbox Code Playgroud)

会打电话

int var1 = Convert<int>(HttpContext.Current.Request.QueryString,"ID", 0);
Run Code Online (Sandbox Code Playgroud)

但是,当尝试执行以下操作时,它无法正常工作,所以我的问题是,如果从querystring变量检索的值是1或0而不是true,则可以更改代码来处理bool.

ie... instead of
http://localhost/default.aspx?IncludeSubs=true
the call is
http://localhost/default.aspx?IncludeSubs=1

bool var1 = Convert<bool>(HttpContext.Current.Request.QueryString,"IncludeSubs", false);
Run Code Online (Sandbox Code Playgroud)

c# int boolean

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