Question: I have a controller that uses Spring to automatically map HTTP request params to business domain objects. I persist the field data in the domain objects to a database.

I have another controller that needs to support searching on any combination of fields related to the domain objects. For some of the fields (e.g. date fields), I need to allow searching within a range. So, I can't reuse the domain objects since it only has a single date field.

For example, I have a Report domain object with a date field. However, the search needs a "from" Report date field and a "to" Report date field.

Should I create a set of domain objects for just searching that mostly mirror the business domain objects (except for fields that support range searches)? Or is there some better way to do this?

Thanks in advance for your help.

Answer: 
Because `Cars` is an object, and objects are `Reference Types` in C#.

When you call this line of code:

```
oneCar = manyCars[2];

```

You are pointing `oneCar` to the memory location of `manyCars[2]`. They are referencing the same object. Updating `oneCar` also updates `manyCars[2]`.

[This link](http://www.albahari.com/valuevsreftypes.aspx) has a good writeup on Reference and Value types.
In c# there are value and reference types - a class is a reference type. Your code above adds three new car objects to the ManyCars list - then sets the OneCar variable to a reference of the 3rd list element - in your case to the F150. You then overwrite the model property with Pinto and then iterate through your list.

You've basically set OneCar to be a pointer to the original Car object. If you want to make a copy of the object that you can then change without affecting the original in the List you need to Clone the Car object not just assign it to the OneCar variable.

Cheers
Simon