c# Linq List<T>.Where().ToList() create new instances of <T> -


i have class, solution. use class list don't want grow unnecessarily.

i search list preexisting entry , return -or- create new entry if need be:

var s0 = _solutions.where(x => x.strtid == strtnodeid && x.endid == endnodeid).tolist(); 

however, linq create new instances when true. but, might see, not want.

the combination of x.startnode && x.endnode unique in instances of _solution

at end need reference 1 instance of _solution being searched for, if exists.

but can aside creating own loop/s?

thanks.

i think trying create class factory out of list, new instance created if 1 doesn't exist or return singleton instance if 1 exist?

in case, forget list , create static class factory instead updates it's internal list newly created class instances.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -