我将Odata v4软件包添加到我的API中,我注意到它将我的Microsoft.AspNet.WebApi软件包更新为5.2.3版本.但是当我尝试使用时
我的WebApiConfig中的odata构建器配置显示错误,如 "无法加载文件或程序集"System.Web.Http,Version = 5.2.2.0'.
config.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
Run Code Online (Sandbox Code Playgroud)
我在我的项目中搜索了这个版本(5.2.2)但是每个东西都是5.2.3并且我也更新了所有的包来解决这个问题但是失败了.对于System.Web.Http dll,复制到本地属性也是如此.
任何的想法?
我期待在ProductController中创建一个未绑定的函数,它返回完全不同的实体(与Product无关).
[EnableQuery]
public class ProductsController : ODataController
{
[HttpGet]
[ODataRoute("InvokeMyUnBoundFunction(Id={id})")]
public IHttpActionResult InvokeMyUnBoundFunction(int id)
{
TestUnBound testObj= new TestUnBound();
testObj.Name = "Test" + id;
return Ok(testObj);
}
}
Run Code Online (Sandbox Code Playgroud)
和我的webApiConfig是
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Product>("Products");
builder.EntitySet<TestUnBound>("TestUnBounds"); //Its not related to Product.
builder.Function("InvokeMyUnBoundFunction").Returns<TestUnBound>().Parameter<int>("Id");
Run Code Online (Sandbox Code Playgroud)
但当我调用 http:// localhost:port/api/odata/InvokeMyUnBoundFunction(Id = 1234)时, 我收到一条错误消息
"无法从OData路径中找到相关的实体集或单例.需要相关的实体集或单例来序列化有效负载."
我错过了任何概念吗?
我想从另一个模型更新现有实体对象。但每次我得到一个新对象(具有映射的属性和其他属性的默认值。)相反,我想要一个部分更新的目标对象。
AutoMapper.Mapper.Initialize(cfg => cfg.CreateMap<Customer, MYPOCO>().ReverseMap());
public void UpdateEntity(Customer customerSrc)
{
MYPOCO pocoDesc= dbContext.DD_POCO.SingleOrDefault(m => m.Id == 123);
pocoDesc = AutoMapper.Mapper.Map<Customer, MYPOCO>(customerSrc, pocoDesc);
// Here "pocoDesc" is a new object, I got only "customerSrc" data and lost all other existing properties values.
}
Run Code Online (Sandbox Code Playgroud)
自动映射器:6.2.2(版本)
任何想法?
根据我的理解,当我们使用await并且等待的任务尚未完成时,执行将返回给调用者.它在服务器端工作正常(从服务器端方法本身调用异步方法).但是当我从UI调用异步方法时会发生什么.
public class TestController : ApiController
{
IList<string> lstString = new List<string>();
public async Task<IList<string>> GetMyCollectionAsync()
{
lstString.Add("First");
string secString = await GetSecondString(); // I am expecting a response back to UI from here.
lstString.Add(secString);
lstString.Add("Third");
return lstString;
}
private async Task<string> GetSecondString()
{
await Task.Delay(5000);
return "Second after await";
}
}
Run Code Online (Sandbox Code Playgroud)
我用浏览器中的上述API测试过
,但是我的UI中只有5秒后才收到回复.我错误地思考了吗?
我正在使用Stripe.Net来处理付款。当我开始测试“ charge.refund” webhook时,我在后面的代码中得到了NULL发票属性,但Stripe webhook事件中存在发票值,并且我确认发票也存在仪表板。
注意Stripe.Net中的版本和配置的webhook API不同。
仪表板Webhook API版本: 2017-08-15
Stripe.Net版本:16.12.0.0(支持2018-02-06)。
这是Stripe Webhook事件
这是中断代码(charge.Invoice.SubscriptionId用空引用中断)
有人遇到过这个问题吗?
谢谢
我的目标是搜索一个单词,而不管添加的分析器是什么。
我将匹配查询与关键字分析器一起使用,但我认为它可以与添加到该属性的默认分析器一起使用。
在弹性搜索中,我的作者文档结构是这样的
"_source": {
"Id": 3,
"Organization": "let123"
}
Run Code Online (Sandbox Code Playgroud)
索引映射:
createIndexDescriptor.NumberOfReplicas(1)
.NumberOfShards(1)
.Settings(
settings =>
settings
.Add("analysis.filter.autocomplete_filter_ngram.type", "edge_ngram")
.Add("analysis.filter.autocomplete_filter_ngram.min_gram", "2")
.Add("analysis.filter.autocomplete_filter_ngram.max_gram", "7")
.Add("analysis.analyzer.title_analyzer.type", "custom")
.Add("analysis.analyzer.title_analyzer.char_filter.0", "html_strip")
.Add("analysis.analyzer.title_analyzer.tokenizer", "standard")
.Add("analysis.analyzer.title_analyzer.filter.0", "lowercase")
.Add("analysis.analyzer.title_analyzer.filter.1", "asciifolding")
.Add("analysis.analyzer.title_analyzer.filter.2", "autocomplete_filter_ngram"))
.AddMapping<Author>(
m =>
m.MapFromAttributes()
.AllField(f => f.Enabled(true))
.Properties(
props =>
props.MultiField(
mf =>
mf.Name(t => t.Organization)
.Fields(fs => fs.String(s => s.Name(t => t.Organization).Analyzer("title_analyzer"))
))));
Run Code Online (Sandbox Code Playgroud)
在这里我注意到我的标题分析器过滤器之一是ngram
但我在匹配查询中使用了关键字分析器,以避免在搜索中自动完成。
GET /author/_search {
"query": {
"match": {
"Organization": {
"query": "le",
"analyzer": …
Run Code Online (Sandbox Code Playgroud) c# ×5
odata ×2
asp.net-mvc ×1
async-await ×1
asynchronous ×1
automapper ×1
nest ×1
stripe.net ×1
webhooks ×1