Record List is List in C#? Does it have .contains() method? How to use it?

Record List is List in C#? Does it have .contains() method? How to use it?

  
Hello,

Record List is List in C#?
Does it have .contains() method?
How to use it?

I wonder if the Outsystems platfform allows the use of this funcionalities or I need to write an extension to do this.

Thanks for your input
Hi Alexandre,

The Outsystems platform has a set of bult-in actions to handling lists. In Forge you can find the ListUtils Extension. It has some functions, but if you want more advanced, you'll need to write your own extension for it. 

Best regards,
Isn't this very lackluster?
If i want to do this operation, i must use a for each cycle to check if the record exists, instead of a simple low level and optimized operation?
I have to agree with you. I've no idea there is no a ListContains bult-in action in Outsystems. In addition to being simpler solution, it's a lot better in performance.
There's an easy answer for why there is no ListContains action: what exactly would it be looking for?

Lists are NOT simple hashes/dictionaries. They can contain nested structures. They can do all sorts of things.

So a "Contains" function needs to work in one of two ways:

1. You provide it with an exact Object, and it lets you know if that objects exists in the List. This is PROBABLY not what you are trying to do! Most likely, you are doing something like seeing if a particular Attribute of one of the records matches a particular value (such as looking for a User record with the Id "543" in a list).

2. The "Contains" function works only on a specific field/property/attribute. For example, a Dictionary would have .ContainsKey and .ContainsValue (which are both Object comparisons usually...).

This is why .NET has LINQ, which in turn required a massive rewrite of the C# language.

This isn't a trivial include for the Platform, it is an engineering undertaking of fairly epic proportions.

J.Ja
It makes perfect sense. Thanks for the great explanation Justin!

But I still think that Outsystems should have a ListContains action only to Text Record Lists to avoid having to use a for each cycle explicitly. With the convertion feature introduced in OS v9, it would be a lot simpler than create a for each cycle with a IF condition to check if it exist on the list.

Best regards,
I subscribe to Andre. It's horrible that a platform with such potential has so many performance issues. Just some months ago a reported an inefficiency in the sql queries generated by the platform and has dynamic size for its data type, opposed to fixed declare size, according to the data base definition. Results? Sql server had to generate a unique plan for each combination of dynamic datatype input, which occupied more than 150mb plans in memory...
Alexandre -

As someone who has been using Outsystems for over 6 years, I can tell you three things:

1. The platform isn't perfect.

2. The platform does better than 90% (or more) of developers. It's nice that a fix in the platform immediately fixesbad code, instead of having to find all of the bad patterns and habits. I will put the code the platform creates up against the typical development team, and the platform will win nearly every time in terms of quality, consistency, performance, and security.

3. OutSystems has been a great vendor, and works very hard to acknowledge and address issues quickly as they come up. Of all of the vendors I have dealt with in my career, OutSystems is one of the best.

So you found an inefficiency? So have I. I've found plenty. All got a fix released within weeks, and OutSystems provided me with a hotfix in many cases. That's better than most internal teams can fix problems within code.

In other words... it's a great system backed by a great company. Find the issues, report them, and watch them get resolved quickly.

J.Ja
Hi Justin, Maybe they handle your feedback with greater priority :-P Well, I think the easy fix for my original question is to make an extension of my own, correct?
Hi Alexandre,

Depends on how you want to compare the records and the amount of reuse you want to give it.

The usual, typesafe and with better performance is to create an action in your module to do a contains for a specific list type.
This has the obvious disadvantage that you need a different action for each list you need to test, but it's the best way.

The alternative, yes, is to do it in an extension but to have it generic for any list (and depending on how complex you want the comparison to be) it requires use of reflection and some non-documented methods to be efficient. You can see the SortRecorlist extension in the forge as an example if you decide to go this way.


Personally I would use the first alternative (and I did a lot in the past), expecially since, like Justin said, most contains operations are usually very effecicient comparisons of a single attribute and depend on the elemeny type.

Regards,
João Rosado
Just to complement my answer here goes the same disclaimer that all the forge components that do untyped operations on records/recordlists have.

Notice: This component takes advantage of private and undocumented Platform APIs, which can change without notice. As a result, this component may unexpectedly break as the Platform is upgraded. We advise proper testing to ensure that your applications continue to work as expected when upgrading/patching the Platform.

Regards,
João Rosado
Ok, I'll try the first approach. Internally, you guys code "for each cycle" element as as a "for each", element from the complex record list, correct? I just want to compare/check contains using the first field, id column/field. Thanks for input.
Absolutely right. I would put a generator up against the vast majority of coders and finding bugs in the generator vs bugs in native code I know which one wins hands down, fact. I have found the people who rejoice as it were in finding a generator bug are the types who simply don't want to use the generator and will takeany opportunity to knock it. Find bug, report it, fixed, helps everyone, end of. Find a bug in native code, fix it, helps just your tiny bit of code, end of.




Justin James wrote:
Alexandre -

As someone who has been using Outsystems for over 6 years, I can tell you three things:

1. The platform isn't perfect.

2. The platform does better than 90% (or more) of developers. It's nice that a fix in the platform immediately fixesbad code, instead of having to find all of the bad patterns and habits. I will put the code the platform creates up against the typical development team, and the platform will win nearly every time in terms of quality, consistency, performance, and security.

3. OutSystems has been a great vendor, and works very hard to acknowledge and address issues quickly as they come up. Of all of the vendors I have dealt with in my career, OutSystems is one of the best.

So you found an inefficiency? So have I. I've found plenty. All got a fix released within weeks, and OutSystems provided me with a hotfix in many cases. That's better than most internal teams can fix problems within code.

In other words... it's a great system backed by a great company. Find the issues, report them, and watch them get resolved quickly.

J.Ja
 
 

If we wanted to address this we would need 2 features in OutSystems.

1. Dynamic typing, which can be as simple as having an untyped "result" variable, the types of which is inferred by what is assigned to it.

2. Functions as parameters to Actions / Functions.

This would effectively allows for delegates. It wouldn't be perfectly elegant yet, for that we would need a lambdas, but these 2 features would solve the majority of painful code in OS. 

Hi,

While there's no generalized support for functions and generic types, the new List actions introduced in OutSystems 10 already improve the platform on that area.

Cheers,

Paulo