小编Sco*_*ker的帖子

Linq - 我如何将这些合并为一个IQueryable?

我有一个简单的(混淆的)类:

public Thing ()
{
    public IList<string> Strings()
    { 
        // returns an IList of whatever, 
        // using strings as an example
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的代码中的其他地方我IQueryable<Thing> things从数据库中检索一个

我的目标是将所有strings从一个things变为一个IQueryable<string> strings,可能是这样的:

var strings = from t in things
              select t.Strings()
Run Code Online (Sandbox Code Playgroud)

但那只能让我受益匪浅IQueryable<IList<string>>.如何将所有这些列表整合到一个无所不包的集合中?

.net c# linq iqueryable

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

同时执行两个数据库调用(使用两个 DbContext)

我需要从两个不同的结果DbContext(针对 Oracle 数据库的两个不同模式)获取结果来填充页面。我想同时执行两个数据库查询(只读,无写操作),并在完成后返回结果。问题是,我是平行世界中的连续剧人,我不了解杰克Async//Await等等TPL……

我有一个Action基本上看起来像这样的控制器:

public Task<IActionResult> Foo(MyViewModel vm)
{
  if (!ModelState.IsValid) return Task.Run(()=> (IActionResult)View(vm));

  var filter = new FilterObject(vm);
  var firstTask = _firstContext.FilterItems(filter); // returns Task<IQueryable<Items>>
  var secondTask = _secondContext.FilterItems(filter); // returns Task<IQueryable<Items>> 

  vm.Result.Clear();
  vm.Results.AddRange(firstTask.Result);
  vm.Results.AddRange(secondTask.Result);

  return Task.Run(()=> (IActionResult)View("Index", vm));
}
Run Code Online (Sandbox Code Playgroud)

DbContext调用过滤器来完成其工作:

public class FirstContext : DbContext
{
  public DbQuery<Items> Items{get;set;}

  public Task<IQueryable<Items>> FilterItems(FilterObject filter)
  {
     filter.ApplyTo(Items.AsQueryable());
  }
}
Run Code Online (Sandbox Code Playgroud)

...我的 FilterObject 修改了 IQueryable:

public class FilterObject …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library async-await ef-core-2.2

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

Axios - 如何对 Get() 请求中的注入值进行编码?

我的 Vue 应用程序中有一个 axios 调用失败:

axios.get(`parts/${item.number}`)
   .then(response => { /* do things */ });
Run Code Online (Sandbox Code Playgroud)

...因为有时item.number包含一个/...在 URL 中包含额外内容并不好。推荐的 HTML 编码方式是item.number什么?

vue.js axios

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

在 Xamarin Forms 中使用 Material Design 图标 - 我错过了什么?

我正在尝试修改默认的 Xamarin Forms (Flyout) 应用程序模板以使用 Material Design Icons 作为FlyoutItem图标,而不是提供的.png文件。我尝试关注James Montemagno 的这篇博客文章,并尝试使用他的Hanselman.Forms项目作为参考……但我遗漏了一些东西。

注意: 此时,我无法使用 iPhone 或 Mac,所以我只专注于 Android 项目。

我已经完成了以下步骤:

  1. materialdesignicons-webfont.ttf文件导入 Assets 文件夹并仔细检查其Build Action是否设置为AndroidAsset.
  2. 将以下内容添加到App.xaml文件中:
<OnPlatform x:Key="MaterialFontFamily" x:TypeArguments="x:String">
   <On Platform="Android" Value="materialdesignicons-webfont.ttf#Material Design Icons" />
</OnPlatform>

<x:String x:Key="IconAbout">&#xf2fd;</x:String>
Run Code Online (Sandbox Code Playgroud)
  1. 修改 AppShell.xaml 以更改图标:
<FlyoutItem Title="About">
   <FlyoutItem.Icon>
      <FontImageSource Glyph="{StaticResource IconAbout}"
                       FontFamily="{StaticResource MaterialFontFamily}" 
                       Color="Black"/>
   </FlyoutItem.Icon>
   <ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</FlyoutItem>
Run Code Online (Sandbox Code Playgroud)

这是从直接复制Hanselman.Forms项目的TabItem-我以为的FontFamily必须是一个DynamicResource,但显然不是,因为它的工作原理如同是在该项目中,但不工作在我的任一方式-该图标始终是空白的(实际上,如果我将 …

android app.xaml xamarin xamarin.forms

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

WPF RichTextbox 从 TextRange 中删除前景信息

抱歉我的英语不好...RichTextBox内容的默认值是从其RichTextBox自身继承前景色。这很好,但如果我Foreground为我的文本的某些部分设置了特定的颜色,那部分显然不再继承Foreground。如何让我的“彩色”文本Foreground再次继承?我正在尝试执行 Office Word 中的“自动”颜色之类的操作,但是在将特定颜色设置为 a 后TextRange,我不知道如何取消设置:/

TextRange.ClearAllProperties()做我需要的,但也会删除其他属性,比如FontSizeFontFamily......

TextRange.ApplyPropertyValue(ForegroundProperty, DependencyProperty.UnsetValue) 也没有做的伎俩......

wpf dependency-properties richtextbox

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

使用WCF将WS-Security凭据添加到SOAP标头

我正在尝试与我无法控制的Java Web服务进行通信,并且我正在尝试创建一个可以正常工作的绑定.

  1. 标头中不允许使用时间戳,因此为了使用该includeTimestamp="false"属性,我必须使用a <customBinding>.
  2. 他们正在使用MTOM,所以我必须使用该<mtomMessagingEncoding>元素.

这是我的<bindings>元素:

<bindings>
  <customBinding >
    <binding name="MyBindingName" >
      <mtomMessageEncoding  />
      <transactionFlow />
      <security authenticationMode="UserNameOverTransport"
                includeTimestamp="false">            
      </security>
    </binding>
  </customBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)

SOAP Web服务要求邮件头采用以下格式:

 <soap:Envelope ... >
  <soap:Header ... >
    <wsse:UsernameToken>
      <wsse:Username>doo</wsse:Username>
      <wsse:Password Type="wsse:PasswordText">fuss</wsse:Password>
    </...>
  </...>
 </...>
Run Code Online (Sandbox Code Playgroud)

我最接近的是:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
            xmlns:a="http://www.w3.org/2005/08/addressing" 
            xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <a:Action s:mustUnderstand="1"></a:Action>
    <a:MessageID>urn:uuid:a368e205-a14d-4955-bf75-049cdd3a78c0</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">https://blablabla</a:To>
    <o:Security s:mustUnderstand="1" 
                xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <o:UsernameToken u:Id="uuid-0f1e399b-31a8-4e00-a57f-277c21e94879-1">
      <o:Username><!-- Removed--></o:Username>
      <o:Password><!-- Removed--></o:Password>
    </o:UsernameToken>
   </o:Security>
 </s:Header>
Run Code Online (Sandbox Code Playgroud)

我相信我在这里错过了一些琐碎和愚蠢的东西,但对于我的生活,我无法弄清楚它可能是什么.

wcf ws-security soap soap-client wsse

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

我如何在我的文本框中放置这样的验证?

public static Boolean TextBoxValidation(TextBox txt, String AdditionalMsg)
{
    if (txt.Text.Trim() == "")
    {
        MessageBox.Show("Please Enter " + AdditionalMsg); 
        return false;
    }

    return true;
}
Run Code Online (Sandbox Code Playgroud)

这是我的代码; 当用户没有填写某些条目时,会显示一条消息.我想要一些更有创意的东西:当用户没有在文本框中填入一些条目时,我的文本框周围会出现一个红色边框,并向用户显示一条消息,就像工具提示一样.

请参阅我上传的图片:

请参阅我上传的图片

.net c# validation winforms

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