小编msp*_*iuk的帖子

启动时没有加载自动映射配置文件?

我正在使用:

  • AutoMapper 6.1.1
  • AutoMapper.Extensions.Microsoft.DependencyInjection 3.0.1

似乎我的配置文件没有被加载,每次我调用mapper.map我得到AutoMapper.AutoMapperMappingException:'缺少类型映射配置或不支持的映射.

这是我的Startup.cs类的ConfigureServices方法

 // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        //register automapper

        services.AddAutoMapper();
        .
        .
    }
Run Code Online (Sandbox Code Playgroud)

在另一个名为xxxMappings的项目中,我有我的映射配置文件.示例类

public class StatusMappingProfile : Profile
{
    public StatusMappingProfile()
    {
        CreateMap<Status, StatusDTO>()
         .ForMember(t => t.Id, s => s.MapFrom(d => d.Id))
         .ForMember(t => t.Title, s => s.MapFrom(d => d.Name))
         .ForMember(t => t.Color, s => s.MapFrom(d => d.Color));

    }

    public override string ProfileName
    {
        get …
Run Code Online (Sandbox Code Playgroud)

c# automapper asp.net-core-2.0

8
推荐指数
2
解决办法
3328
查看次数

带有HashMap的XStream <String,String>

任何人都可以告诉我如何使用XStream序列化HashMap?

private HashMap<String,String> attributes;
attributes = new HashMap<String,String>();
attributes.put("Description","Value");
attributes.put("Description2","Value2");
attributes.put("Description3","Value3");
Run Code Online (Sandbox Code Playgroud)

我的xml看起来像

<attributes>
       <entry>
           <string>Description</string>
           <string>value</string>
       </entry>
       <entry>
           <string>Description2</string>
           <string>Value2</string>
       </entry>
       <entry>
           <string>Description3</string>
           <string>Value3</string>
       </entry>
    </attributes>
Run Code Online (Sandbox Code Playgroud)

我想要一个输出

<attributes>
    <attr>
        <description>Description</description>
        <value>Value</value>
    </attr>
    <attr>
        <description>Description2</description>
        <value>Value2</value>
    </attr>
    <attr>
        <description>Description3</description>
        <value>Value</value>
    </attr>
</attributes>
Run Code Online (Sandbox Code Playgroud)

怎么用XStream实现呢?是否可以注释?

java annotations xstream hashmap xml-serialization

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

kendo ComboBox查找并选择值(如果存在)

我有一个kendo组合框,并且还有一个带值的变量.如何在组合框中搜索值,如果存在,请选择它?全部使用javascript/Jquery

http://jsfiddle.net/mspasiuk/8HnnZ/

var movieId=10;


var combo =$("#movies").kendoComboBox({
    dataTextField: "text",
    dataValueField: "value",
    dataSource: data,
    height: 100
});
Run Code Online (Sandbox Code Playgroud)

我找不到如何设置值和Id.所以我的问题是如何将selectedIndex或Value设置为我所拥有的,如果不存在,则将selectedIndex设置为-1

jquery kendo-ui kendo-combobox

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

lodash获取按键分组的元素数组

我有一个API调用返回的JSON数组

[{
    "id": 1,
    "name": "aa",
    "zone": 1

}, {
    "id": 2,
    "name": "bb",
    "zone": 1

}, {
    "id": 3,
    "name": "cc",
    "zone": 2

}, {
    "id": 3,
    "name": "dd",
    "zone": 2
}
]
Run Code Online (Sandbox Code Playgroud)

通过使用lodash,我_.groupBy(myData,'zone')得到了一个对象,其中包含2个数组,每个数组用于一个不同的区域。但是我需要实现的是,在一个包含区域数组并且每个区域都有一个关联名称数组的对象中。

所需结果:

[
   {
      "zone": "1",
      "items": [
         {
            "id": 1,
            "name": "aa",
            "zone": 1
         },
         {
            "id": 2,
            "name": "bb",
            "zone": 1
         }
      ]
   },
   {
      "zone": "2",
      "items": [
         {
            "id": 3,
            "name": "cc",
            "zone": 2
         },
         {
            "id": 3,
            "name": "dd", …
Run Code Online (Sandbox Code Playgroud)

javascript arrays typescript lodash angular

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