小编use*_*375的帖子

如何从t-sql中的xml变量获取节点名称和值

我有以下xml -

<Surveys xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ImmForm XML Schema NHS Direct.xsd"><Svy SurveyName="WeeklyFluSurveillance2012/13-NHSDirectWeek40w/e07/10/2012" OrgCode="NHS Direct"><TotCR>222.10</TotCR><PerCF>0.40</PerCF><PerCFunder1>0.20</PerCFunder1><PerCF1to4>0.30</PerCF1to4><PerCF5to14>0.50</PerCF5to14><PerCF15to44>0.40</PerCF15to44><PerCF45to64>0.20</PerCF45to64><PerCF65plus>3.60</PerCF65plus>
<PerCFNE>4.22</PerCFNE>
<PerCFNW>6.50</PerCFNW>
<PerCFYH>0.80</PerCFYH>
<PerCFEM>1.00</PerCFEM>
<PerCFWM>1.50</PerCFWM></Svy></Surveys>
Run Code Online (Sandbox Code Playgroud)

我需要在结果集中选择子节点名称及其值,其中包含2列(FieldName,FieldValue),如 -

TotCR   222.10
PerCF     0.40
...
PerCFWM   1.50
Run Code Online (Sandbox Code Playgroud)

xml中的节点会有所不同,但可能并不总是相同.甚至值也可以是整数或文本.

你们可以在SQL Server 2008 R2中使用OPENXML建议如何做到这一点吗?

sql t-sql sql-server xpath sql-server-2008-r2

11
推荐指数
1
解决办法
4万
查看次数

通过 ActionExecutingContext 从控制器 .Net Core 获取自定义属性

这曾经用于早期版本的 .Net。.net 核心术语中的等价物是什么。现在我收到以下错误:

“ActionDescriptor”不包含“ GetCustomAttributes ”的定义,并且找不到接受“ActionDescriptor”类型的第一个参数的扩展方法“ GetCustomAttributes

public virtual void SetupMetadata(ActionExecutingContext filterContext)
{
    var myAttr = filterContext.ActionDescriptor.GetCustomAttributes(typeof(MyAttribute), false);
    if (myAttr.Length == 1)
        //do something
}
Run Code Online (Sandbox Code Playgroud)

属性定义:

public class MyAttribute : Attribute
{
    private readonly string _parameter;

    public PageTitleAttribute(string parameter)
    {
        _parameter = parameter;
    }

    public string Parameter { get { return _parameter; } }
}
Run Code Online (Sandbox Code Playgroud)

代码用法:

[MyAttribute("Attribute value is set here")]
public ActionResult About()
{
    ViewBag.Message = "Your application description page.";
    return View();
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-core

9
推荐指数
3
解决办法
7772
查看次数

使用Moq .net Core对fileupload进行单元测试

我在WebApi控制器中有一个方法,我想编写单元测试.这是我的控制器方法的样子:

Controller.cs

public async Task<FileUploadDto> UploadGoalDocument(Guid id)
    {
        var file = this.Request?.Form?.Files.FirstOrDefault();
        FileUploadDto result = null;

        if (file == null)
        {
            return this.CreateResponse(result);
        }

        //logic to store file in db

        return this.CreateResponse(new FileUploadDto() { Id = document.Id, Name = document.Name, Uri = document.Uri});
    }
Run Code Online (Sandbox Code Playgroud)

如何在单元测试中模拟请求对象?我尝试了以下但遇到了IFormFileCollection的问题.以下行抛出错误:

找不到system.argumentexception接口

cc.Setup(x => x.HttpContext.Request.Form.Files).Returns(col.Object);
Run Code Online (Sandbox Code Playgroud)

ControllerTest.cs

public async Task Upload_document_should_upload_document_and_return_dto()
    {
        var fileDto = new FileUploadDto { Id = Guid.NewGuid(), Name = "dummy.txt" };

        var fileMock = new Mock<IFormFile>();
        //Setup mock file using a memory stream …
Run Code Online (Sandbox Code Playgroud)

.net c# unit-testing moq asp.net-core

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

即使有建议的尺寸,Facebook OpenGraph图像也会被裁剪

我刚刚通过设置开放图元标记在我的网站(http://traveleagle.in)上添加了facebook社交插件.根据最近的指南,我在og:图像中使用了大小为600x315的png图像,这意味着建议的宽高比为1.91:1.问题是即使使用Facebook的lint工具(https://developers.facebook.com/tools/debug)正确显示og:图像,共享插件上的图像也会被裁剪(154x154).我符合最小图像大小标准,但插件不显示完整的图像,并始终裁剪它.还有其他人有类似的问题吗?

facebook facebook-graph-api

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

在SendGrid C#中将电子邮件作为日历邀请/约会发送

我想将带有日历邀请/约会的电子邮件发送到Outlook以及非Outlook客户端(例如gmail / yahoo)。我的应用程序托管在Azure上,并且我正在使用SendGrid发送电子邮件。电子邮件部分工作正常,但是我还没有找到可以与Outlook和其他电子邮件客户端一起使用的完全正常的解决方案。这是我用来发送电子邮件的代码段:

var client = new SendGridClient(this.apiKey);
var msg = MailHelper.CreateSingleEmailToMultipleRecipients(
            new EmailAddress(Sender, SenderName),
            recipients, subject, textcontent, htmlcontent);

if (isMeetingRequest)
{
    Attachment attachment = new Attachment(); 
    attachment.Filename = "calendar.ics";
    attachment.Content = htmlcontent;
    attachment.Type = "text/calendar";
    msg.Attachments = new List<Attachment> { attachment };
}
await client.SendEmailAsync(msg);
Run Code Online (Sandbox Code Playgroud)

htmlContent来自另一个编码片断的形式日历邀请字符串:

private static string MeetingRequestString(string from, List<string> toUsers, string subject, string desc, DateTime startTime, DateTime endTime)
    {
        StringBuilder str = new StringBuilder();

        str.AppendLine("BEGIN:VCALENDAR");
        str.AppendLine("PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN");
        str.AppendLine("VERSION:2.0");
        str.AppendLine(string.Format("METHOD:REQUEST"));
        str.AppendLine("BEGIN:VEVENT");

        str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime)); …
Run Code Online (Sandbox Code Playgroud)

c# email outlook azure sendgrid

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

sql71501 sql参数具有未解析的内置类型Visual Studio 2012 DB项目的引用

我在VS2012中的数据库项目出现以下错误.当我在VS2012中的数据库项目中添加自定义类型时,问题就开始了.

CREATE TYPE [dbo].[DestAttractions] AS TABLE(
[TAAttractionId] [varchar](10) NOT NULL,
[TARatingImgUrl] [varchar](256) NULL,
[TAReviewCount] [int] NULL,
[TAReviewUrl] [varchar](256) NULL)
Run Code Online (Sandbox Code Playgroud)

当我尝试引用存储过程中的类型时,它也是数据库项目的一部分

CREATE PROCEDURE [dbo].[spupd_DestinationTripAdvisorData]
@DestinationId INT,
@TAAwardImgUrl VARCHAR(256),
@Attractions dbo.DestAttractions READONLY
AS
BEGIN

------
------
END
Run Code Online (Sandbox Code Playgroud)

并构建数据库项目,我继续得到以下错误,这是非常烦人的,因为存储过程完美无缺,并且类型没有问题.

SQL71501:参数:[dbo].[spupd_DestinationTripAdvisorData].[@ Attractions]有一个未解析的内置类型[dbo]的引用.[DestAttractions].任何指针或帮助将非常感激.

database project visual-studio-2012 sql-server-data-tools

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

正则表达式 - 允许使用字母,撇号,句号,逗号和连字符

我正在为这个小而又令人困惑的要求而烦恼.

我需要一个名称字段的正则表达式,它只允许字母,撇号,句号,逗号和连字符.名称字段也不应允许超过150个字符.

任何帮助将非常感激!

html javascript java regex jquery

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

如何以编程方式连接到 WiFi

我正在尝试使用应用程序连接到新的 wifi 网络,而不是使用以下代码的 android wifi 设置,但似乎相关的 android sdk 类只允许您连接到已存储在 android 中的网络,而不是任何新网络。我的想法正确吗?

这是我的代码

清单 XML:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="unitedspark.testapp" >
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".WiFiConnect"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<receiver android:name=".WiFiChangeReciever" >
    <intent-filter>
        <action android:name="android.net.wifi.STATE_CHANGE" />
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    </intent-filter>
</receiver>
</manifest>
Run Code Online (Sandbox Code Playgroud)

活动 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".WiFiConnect"
android:id="@+id/WiFiConnectLayout">

<TextView
    android:id="@+id/Connect"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-wifi

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

LINQ过滤结果基于另一个列表之间的值

我有一个特殊的问题,我需要根据价格范围过滤我的搜索结果.所以我有2个清单:

列表A包含所有项目及其价格.

列表B包含所有价格范围,如价格b/w 20和30以及价格在50-60之间.

现在我需要在A中过滤结果,其中价格介于列表B中指定的价格范围之间.

我的linq查询是:

A - 产品数据

var list = (from a in db.MItems
                        join b in db.DCategoryProducts on a.ProductCode equals b.ProductCode
                        join c in db.DItemTargetAreas on a.ProductCode equals c.ProductCode
                        join d in db.DItemQuantities on a.ProductCode equals d.ProductCode
                        where a.IsActive && b.ItemCategoryCode == itemCategoryID
                        && !string.IsNullOrEmpty(_targetarea) ? _targetarea.Contains(c.TargetArea.ToString()) : c.TargetArea == c.TargetArea
                        && !string.IsNullOrEmpty(_compression) ? _compression.Contains(a.CompressionRating.ToString()) : a.CompressionRating == a.CompressionRating
                        && !string.IsNullOrEmpty(_color) ? _color.Contains(d.ColourCode.ToString()) : d.ColourCode == d.ColourCode
                        && !string.IsNullOrEmpty(_style) ? _style.Contains(d.StyleCode.ToString()) : d.StyleCode == d.StyleCode …
Run Code Online (Sandbox Code Playgroud)

c# linq

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