How to troubleshoot automapper when map one object to another - automapper

I have this line of code
var bilagaAttSpara = _mapper.Map(blankettUtskick.Bilaga);
bilagaAttSpara is alwaws null , How can I check why ?

Related

NotesException: Unknown or unsupported object type in Vector

I'm trying to add new names to the address book programmatically but I'm getting the following error:
[TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Array)
Unknown or unsupported object type in Vector
Code snippet below:
var addressBook = session.getDatabase("","names.nsf");
var gView:NotesView = addressBook.getView("($VIMGroups)");
var gDoc:NotesDocument = gView.getDocumentByKey("groupName", true);
var newg:java.util.Vector = [];
var mems:java.util.Vector = new Array(gDoc.getItemValue('Members'));
newg.push(mems);
var newNames:java.util.Vector = new Array(getComponent("NewMems").getValue());
newg.push(newNames);
gDoc.replaceItemValue("Members", newg);
gDoc.save();
Adding a single user works fine, but then it does not save users in the required canonical format below:
CN=John Doe/O=Org
Instead it is saved in the original format below:
John Doe/Org
I look forward to your suggestions. Thanks.
You can't store an Array in a field. Make newg a java.util.Vector instead and integrate with that.
For OpenNTF Domino API the team wrote a lot of code to auto-convert to Vectors, which may cover Arrays.
Don't use an Array (which is a JS thing). Initialize it as a Vector.
var newg:java.util.Vector = new java.util.Vectory();
Then look up the Vector methods to see how to add to that vector. Not sure if you will have to convert the names using the Name method but I would store them as "CN=Joe Smith/O=Test Org" to be sure you got the right format.
I was able to solve the issue using a forloop to loop through the list and push it into a newly created array. Using the forloop seems to make the difference.
var newg = [];
var group = new Array(getComponent("NewMems").getValue()), lenGA = group.length;
for(i = 0; i < lenGA; i++){
newg.push(group[i]);
}
gDoc.replaceItemValue("Members", newg);
gDoc.save();
An explanation about this behaviour will be appreciated.

Determine if a node exists in HTMLAgiltyPack

I want run a foreach loop in a HtmlNode which has been parsed from internet via HtmlWebclass and loadFromWebAsync method. Before running the loop I want to make sure the that the node exists in the HtmlDocument. How do I check that without the help Xpath query because many of the Windows RT and Windows 8.1 version doesn't work with this.
You can use LINQ .Any() method to check if sequence contains any element, for example :
var doc = new HtmlDocument();
.....
var isDivExist = doc.DocumentNode
.Descendants("div")
.Any();
Or to check if any node in the sequence satisfies specific condition :
var isDivWithSpecificClassExist = doc.DocumentNode
.Descendants("div")
.Any(d => .GetAttributeValue("class", "") == "foo");

Assigning a value to the primary field in code fails

I have a custom entity named eld_timereg. This entity has an attribute named eld_name (which is the primary field). Records are created in a generic handler (after pushing a button in the ribbon). I'm using late binding.
var myService = ...;
var t = new Entity( "eld_timereg" );
t["field1"] = "abc";
.
.
.
t["eld_name"] = GenerateAnUniqueStringCode("ZXC");
// returns something like ZXC-16398-T1VC
return myService.Create(t);
The record is created without any error. Checking the entity in SSMS, the value is blank although it is a required field.
What is happening here?
Found the problem. You put me on the right track James. Thank you for that. The eld_name attribute was overwritten in the plug-in (I forgot). Here it should be filled with some information. This was going wrong and always returned a null.

Get an object from ObservableColelction with condition

I have an ObservableColection totalsCol and want to retrieve an object whose id matches the specified id. I coded as :
IEnumerable<Totals> ie = totalsCol.Where(a => a.IdCTS == ct1.TOR_Id);
if (ie.Count() > 1)
{
// Update the TotalCts of Totals object
ie.ElementAt(0).TotalCTS = ct1.TotalCts;
CalculateTotalsPercent();
}
I get ie.count as null. Whereas it has 3 records. And on debugging, I can see that under Source of base.
Where am I wrong here ? I beleive the way am updating the the value with ie.ElementAt will reflect changes in totalsCol observableCollection.
Kindly help me out.
I implemented :
totalsCol.First(a => a.IdCTS == ct1.TOR_Id);
and solved the issue.

Left Join in Subsonic3

I'm new in subsonic3, and I'm getting some errors when I try to use LeftJoin
var q =
from c in categories
join p in products on c equals p.Category into ps
from p in ps.DefaultIfEmpty()
select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName };
The error is
"System.Collections.Generic.Enumerable '...' cannot be used for parameter of type System.Linq.IQueryable
Does anyone had this error before? Did you fix it?
Thanks
I don't know which one is the IQueryable property but you probably know, just add the .AsEnumerable() method.
categories.AsEnumerable() or products.AsEnumerable()
I cant remember if you had to add the toList() method also but you can try it out.
categories.AsEnumerable().toList() or products.AsEnumerable().toList()

Resources