Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Forum Post: Reference remove issue with FilterExpression Unable to create independent copy of FilterExpression

$
0
0
Hi All, I am working on QueryExpression where I added FilterExpression to add Filters and Conditions. I surprised to see that I cannot modify a FilterExpression say fExp2 which derived from another FilterExpression say fExp1. When I am trying add/remove any Filters in fExp2, same is also reflecting in fExp1. Let me put you into the code for better understanding. FilterExpression filterSearch = new FilterExpression (); filterSearch.FilterOperator = LogicalOperator .And; filterSearch.AddFilter(new FilterExpression ()); // Added one filter (showing you just for example where 3 Conditions added in this Filter) // Now creating a copy of it. FilterExpression filterExpressionAliasHistory = new FilterExpression (); filterExpressionAliasHistory.Conditions.AddRange(( ArrayList )filterSearch.Conditions.Clone()); filterExpressionAliasHistory.Filters.AddRange(( ArrayList )filterSearch.Filters.Clone()); filterExpressionAliasHistory.FilterOperator = filterSearch.FilterOperator; // Now removing one Condition from filterExpressionAliasHistory (( FilterExpression )filterExpressionAliasHistory.Filters[0]).Conditions.RemoveAt(0); Here when I am checking filterSearch, I am not able to find that ConditionExpression which I just removed from filterExpressionAliasHistory. Why this is happening? My objective is to build 2-QueryExpression where 2nd should be copy of 1st one but with some less filters. Please suggest me anything using which I can create a independent copy of FilterExpression.

Viewing all articles
Browse latest Browse all 71679

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>