How to use Map in Postman Variables? - postman

Please help me understand how to use the Map in Postman.
For example,
in first test case I declared map like this:
let map = new Map();
map.set('first', 'value1');
pm.collectionVariables.set('map', map);
In second test case how to use this map?
I try like this, but not working:
let map = pm.collectionVariables.get("map");
typeAttrId.set('second', 'value2');
How to convert Postman variable to Javascript Map?
Thank you!

Related

Trying to find a way to convert two lists into a map where one list acts as the key and the other as the value

Trying to find a way to convert two lists into a map where one list acts as the key and the other as the value. I'm new to dart and trying to exercise some of the functions I learned but can't seem to find an effective way to do so.
I tried to convert 1 list to a map and then access the keys in a for loop and replace them with the values from the other list, but apparently that's not possible?
Any suggestions will be appreciated :)
Thanks
EDIT: ok I feel dumb.
This is the solution for anyone wondering.
final theMap = Map.fromIterables(months, salesFigures);

Salesforce - How to split list in Apex

I have a list of a custom object Product like this:
Product:[type=fruit, productValue=apple], Product:[type=fruit, productValue=pinapple], Product:[type=vegetable, productValue=potato],Product:[type=vegetable, productValue=carrot]
I want to obtain two lists due to the first value (type=fruit/vegetable), in Apex WITHOUT using a for cycle.
Expected result: fruitList=['apple','pinapple'] and vegetableList = =['potato','carrot']
How can I split them?
I suggest you can create a Wrapper class for Product with two variable type and productValue with String data type, as written below -
public class Product{
String type;
String productValue;
}
Then use the Wrapper instance to get the list of type and productValue easily with the help of JSON.serilize() and JSON.deserilize()
Please, let me know if it helps you out or not.
Thanks.
There is no way to split them without a loop. Unless you do it before you obtain the list. I would suggest either 2 queries to get the list of products, or just do the loop to split them up. Depends on where you are with governor limits.

I can't directly cast object in my Entity Framework query using ValueInjecter

I'm trying to use ValueInjecter to map my entities to my DTOs in my asp.net core project.
Could someone explain me why this works:
var list = _context.Assets
.ToList();
var vm = list
.Select(a => new ViewModel().InjectFrom(a))
.Cast<ViewModel>()
.ToList();
return vm;
But this doesn't:
var list = _context.Assets
.Select(a => new ViewModel().InjectFrom(a))
.Cast<ViewModel>()
.ToList();
return list;
Is this a ValueInjecter bug? Am I doing something wrong?
Would Automapper solve this? I strongly prefer valueinjecter syntax compared to Automapper.
Thanks for your help!
Edit:
#Chris Pratt: Thanks for your quick answer. But why would it work when I map properties manually like the example below. I'm still applying this mapping to the IQueryable interface not in-memory.
Then why this works?
var vm = _context.Assets
.Select(a => new ViewModel
{
Id = a.Id,
Code = a.Code
})
.AsNoTracking()
.ToList();
return vm;
I haven't used ValueInjector, but my guess is that it comes down to the Select being applied in-memory in the first example and to the query in the second example. Dynamic mapping is not something that can be done at the database level, and specifically, EF must be able to translate the things you pass in Select, Where, etc. into SQL. It will not be able to do so with the ValueInjector code, and hence cannot construct a query to satisfy the LINQ expression. You do not have this issue in the first example, because you pull then entities from the database first, and then you map those in-memory instances.
For what it's worth, AutoMapper would have the same problem here, so it's not technically a mapping provider problem - just one of where the operation is going to be run (i.e. in-memory vs. at the database).

how to copy datagrid itemsource into observable collection object in silverlight5?

I have a values in DataGrid like Name,Age,Address. I have to get datagrid values into Observable collection Object?Is it possible. .If Yes then plz anyone can tell me the solution?
(sorry for my bad english)
Why you simply dont create a ObservableCollection in the first place instead of using a List?
Anyway, you can create an ObservableCollection with the List data this way:
ObservableCollection<Customer> customers = new ObservableCollection<Customer>(YOUR_LIST);
If you really need to get the data from the DataGrid ItemsSource:
ObservableCollection<Customer> customers = new ObservableCollection<Customer>(grid.ItemsSource as List<Customer>);

Condition in generic lists

I'm wondering is there any condition instead of T-SQL like in generic lists in C# 4.0.
I've got a gridview on my page I got all datas and I need to search by name and lastname, so I think there must be but I couldn't find yet.
Use String.Contains, String.StartsWith or String.EndsWith as part of a predicate, either using List<T>.FindAll or Where in LINQ.
For example:
var jons = people
.Where(p => p.FirstName.StartsWith("Jon", StringComparison.CurrentCultureIgnoreCase))
.ToList();
Thats called Contains