Hello all, I wonder if anyone has run into this data manipulation problem when upgrading. I’ve gone down every path I can think of and drawing a blank, and yet I think it’s just a syntax issue.
After using info here C# Customization Error After Upgrade
I’ve been able to upgrade most of our customizations. Our original integration partner used a template with a “GetNewBO” extension that stopped working due to WCF changes. Their template is beyond my skill level, and what little commenting there is isn’t in English, and appears to assume a much better programming knowledge than I have.
I’ve largely resolved it by replacing (for example)
using (var bo = oTrans.GetNewBO<SalesOrderImpl, SalesOrderSvcContract>())
{
bool morePages = false;
var ds = bo.GetRows("OrderNum = " + orderNum.ToString(),
"", "", "", "", "", "OrderLine = " + orderLine.ToString(),
"", "", "", "", "", "", "", "", "", "", -1, -1, out morePages);
}
with
using (var soBO = WCFServiceSupport.CreateImpl<SalesOrderImpl>
((Ice.Core.Session)oTrans.Session,SalesOrderImpl.UriPath))
{
bool morePages = false;
var soDS = soBO.GetRows("OrderNum = " + orderNum.ToString(),
"", "", "", "", "",
"OrderLine = " + orderLine.ToString(),
"", "", "", "", "", "", "", "", "", "", -1, -1, out morePages);
}
After enabling WCFServiceSupport using the script that ships with Kinetic, mentioned in the article referenced above.
Mostly I can get anything I want out of soDS
. However, I’m running into cases where the original customization indexes objects and that’s no longer available. What little LINQ I’ve been able to use doesn’t seem to apply to whatever I’m outputting from GetRows()
even though the two versions of BL Tester appear to do the same thing.
So for example, the original developer pulls a list of OrderRels like this in 10.2.700:
var availRels = ds.OrderRel.Where<SalesOrderDataSet.OrderRelRow>(r => ((Guid)r["VinID_c"]).ToString("D") == "00000000-0000-0000-0000-000000000000");
and now that throws
“Erp.BO.SalesOrderDataSet.OrderRelDataTable’ does not contain a definition for ‘Where’ and the best extension method overload ‘System.Linq.Queryable.Where(System.Linq.IQueryable, System.Linq.Expressions.Expression<System.Func<TSource,bool>>)’ has some invalid arguments”
I eventually abandoned that format of query and this worked:
var availRels = (from SalesOrderDataSet.OrderRelRow rmvRelRow in soDS.OrderRel
where rmvRelRow["VinID_c"].ToString() == "00000000-0000-0000-0000-000000000000" select rmvRelRow);
I was able to get data, for example var availQty = availRels.Sum(r => r.SellingReqQty);
works fine.
I could also access individual column from the first row, availRels.AsEnumerable().FirstOrDefault()["WarehouseCode"].ToString()
worked fine.
But some of the customizations use indexes in a loop, for example
orderRel.Plant = availRels[i].Plant;
, which threw a new kind of error:
“Cannot apply indexing with [] to an expression of type ‘System.Collections.Generic.IEnumerable<Erp.BO.SalesOrderDataSet.OrderRelRow>’”
And where the original uses availRels.Count
in a conditional, it also gave:
“Operator ‘>’ cannot be applied to operands of type ‘method group’ and ‘int’”
My output is still coming from GetRows()
so I wonder if the implementation has changed in Kinetic?
At first I was able to solve this by adding .ToList();
to my query. Anywhere I’m only reading from the data, that list syntax and its associated indexing works the same as whatever was there before.
But now I’m running into loops where the var that is taken from soDS
is being updated, and I’m not clear on how it gets back into soBO.Update();
if it has been modified with .ToList();
Anybody have any thoughts? In the meantime I’ll try to implement this with .ToList()
and report what happens.
.