小编Rag*_*hav的帖子

从 Nest 客户端 ElasticSearch 6.4 序列化查询

直到 ElasticSearch 6.0,我们都能够将搜索请求(SearchRequest 的对象)序列化为字符串

        using (System.IO.MemoryStream mStream = new System.IO.MemoryStream())
        {
            ElasticClient.Serializer.Serialize(searchRequest, mStream);
            string rawQueryText = Encoding.ASCII.GetString(mStream.ToArray());
        }
Run Code Online (Sandbox Code Playgroud)

示例也在这里序列化来自 Nest 客户端弹性搜索 2.3 的查询

但在已删除的 6.4 版本中,我无法准确找到使用 6.4 版本 https://github.com/elastic/elasticsearch-net序列化查询的文档在哪里

有人可以帮我吗?

elasticsearch elasticsearch.net

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

从Redis通过protobufnet反序列化大量用户定义对象时的性能问题

问题:在反序列化从Redis接收的字节时面临性能下降.

我正在使用REDIS在我的ASP.NET Web应用程序中分发缓存.

为了与我的应用程序中的Redis交谈,我正在使用StackExchange.Redis.

为了序列化/反序列化从/向DTO接收/从服务器接收的字节,我使用的是protobuf-net

我的目标是将100,000个用户的字典(Dictionary(int,User))存储到Redis中,并在单个请求中多次检索它.

该字典将驻留在MyContext.Current.Users属性下.该字典的键是用户ID,值是完整的dto.我现在面临的问题是,从字节反序列化100,000个用户需要1.5-2秒(Redis给我字节).我必须在我的请求中多次使用该属性.

public Dictionary<int, User> Users
{
    get
    {
        // Get users from Redis cache.
        // Save it in Redis cache if it is not there before and then get it.
    }
}
Run Code Online (Sandbox Code Playgroud)

用户是在我的上下文包装器类中公开的属性.

这是我为用户提供的DTO(此DTO拥有超过100个属性):

[ProtoContract]
public class User
{
    [ProtoMember(1)]
    public string UserName { get; set; }

    [ProtoMember(2)]
    public string UserID { get; set; }

    [ProtoMember(3)]
    public string FirstName { get; set; }

    .
    .
    . …
Run Code Online (Sandbox Code Playgroud)

c# protobuf-net redis stackexchange.redis

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

如何自动更正方法的xml文档

在xml文档中的以下代码中,方法参数中的参数名称与xml文档中的参数名称不匹配.有没有办法自动更正xml文档签名或resharper中提供的任何功能来自动更正xml文档.

#region Get Images

/// <summary>
///  Get Images 
/// </summary>
/// <param name="par1"></param>
/// <param name="par2"></param>
/// <returns></returns>
public Collection<UserImage> GetImages()
{
    return GetImages("");
}

/// <summary>
///  Get Images 
/// </summary>
/// <param name="par1"></param>
/// <param name="par2"></param>
/// <returns></returns>
public Collection<UserImage> GetImages(string imageType)
{
    return GetImages(0, imageType);
}

/// <summary>
///  Get Images 
/// </summary>
/// <param name="par1"></param>
/// <param name="par2"></param>
/// <returns></returns>
public Collection<UserImage> GetImages(int imageId)
{
    return GetImages(imageId, "");
}

/// <summary>
///  Get Images 
/// …
Run Code Online (Sandbox Code Playgroud)

c# resharper xml-comments resharper-4.5

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

ASP.NET的jQuery图表控件

我想知道一些可以与我的ASP.NET应用程序集成的好的jQuery图表控件.

javascript asp.net jquery charts

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

来自Web UI的死锁.Result

我正在阅读以下主题http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

并决定在我的库中编写一个通用的实用工具方法,通过HTTPClient对远程URL进行GET

public static async Task<T> GetAsync<T>(HttpGetObject getObject)
{
    string baseUrl = getObject.BaseUrl;
    string actionUrl = getObject.ActionRelativeUrl;
    string acceptType = getObject.AcceptType;

    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri(baseUrl);
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptType));

        AddCustomHeadersToHttpClient(client, getObject);

        // HTTP GET
        HttpResponseMessage httpResponseMessage = await client.GetAsync(actionUrl).ConfigureAwait(false);
        if (httpResponseMessage.IsSuccessStatusCode)
        {
            T response = await httpResponseMessage.Content.ReadAsAsync<T>().ConfigureAwait(false);
            return response;
        }
        else
        {
            string message = httpResponseMessage.Content.ReadAsStringAsync().Result;
            throw new Exception(message);
        }
    }
    return default(T);
}
Run Code Online (Sandbox Code Playgroud)

我知道"等待httpResponseMessage.Content.ReadAsAsync().ConfigureAwait(false)"将阻止上述代码中的死锁第一:我的查询是针对"string message = httpResponseMessage.Content.ReadAsStringAsync().结果"行,将.结果是否会导致该行死锁?

第二:如果我从UI调用这样的代码:

public static object DoGet() …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net async-await

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