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.
`manyCars[2]` is the Ford. So after the assignement `oneCar` is the same Ford. But remember that class types are reference types. This means that `oneCar` and `manyCars[2]` point to the same car object! Therefore setting `oneCar.model = "Pinto"` has the same effect than setting `manyCars[2].model = "Pinto"`.

`oneCar = manyCars[2];` does not create a copy of the objects content. You could add a `Clone` method to the cars class

```
public Cars Clone()
{
    return (Cars)MemberwiseClone(); // This method is inherited from object.
}

```

Then this really creates a copy

```
oneCar = manyCars[2].Clone();

```

Now `oneCar` and `manyCars[2]` are two distinct objects and changing `oneCar's` model won't affect the model of `manyCars[2]`.