给定对象集合'items'的linq表达式,例如:
var total = (from item in items select item.Value).Distinct().Count()
Run Code Online (Sandbox Code Playgroud)
是否可以将其转换为使用linq函数/ lambdas:
items.Select(???).Distinct().Count()
Run Code Online (Sandbox Code Playgroud) 我最初几次尝试创建自托管服务.尝试创建一些接受查询字符串并返回一些文本但有一些问题的东西:
所有文档都讨论了如果在配置文件中找不到端点,则会自动为每个基址创建端点.这对我来说似乎不是这样,我得到"服务没有应用程序端点......"的例外情况.手动指定基本端点如下所示似乎解决了这个问题:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace TestService
{
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
string SayHello(string name);
}
public class HelloWorldService : IHelloWorldService
{
public string SayHello(string name)
{
return string.Format("Hello, {0}", name);
}
}
class Program
{
static void Main(string[] args)
{
string baseaddr = "http://localhost:8080/HelloWorldService/";
Uri baseAddress = new Uri(baseaddr);
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = …Run Code Online (Sandbox Code Playgroud)因此,我将通过自托管(在WindowsService中)WebServiceHost(不确定如何使用ServiceHost处理HTTP GET/POST)提供一些功能,其中一个可能被称为大量时间.此功能还将依赖于appdomain中的连接(由WindowsService托管,因此它可以在多个请求中保持活动状态).
我有以下疑虑,非常感谢任何意见/想法/意见:
这就是目前的情况;)我已经在WCF上阅读了很多,并希望我很久以前就已经进入了它,但绝对还在学习.
self-hosting ×2
wcf ×2
c# ×1
concurrency ×1
distinct ×1
endpoints ×1
html ×1
lambda ×1
linq ×1
select ×1
servicehost ×1
xml ×1
xpath ×1
xslt ×1