Question: I have a bash array of floating point numbers, say it is called `vals` and intialized like this --

```
# load data from the datafile.txt

vals=`cat datafile.txt` 
vals=($vals)

```

The `datafile.txt` looks like this --

```
0.012256791324227446
0.012424287090558156
0.013912725724889032
0.014678182257134693

```

Now I need to calculate the average of element 1 and 2 in `vals` using bc, I am doing as follows --

```
result=$(echo "(${vals[1]} + ${vals[2]})/2.0" | bc)
echo result: $result

```

but the `result` is always `0`, please note that the elements are not `0.0`. 

any idea?

**EDIT : The data are changed.**

Answer: 
Use [`SelectMany`](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.selectmany.aspx) in order to flatten `IEnumerable<IEnumerable<CarType>>` into `IEnumerable<CarType>`.

```
var carTypes =
    db.tblPeople
      .Where(p => p.id == id)
      .SelectMany(s =>
          s.tblCars
           .Select(z => z.tblCarType))
      .ToList();

```

This translates from

```
var carTypes =
    (from person in tblPeople
     from car in person.tblCar
     from carType in car.tblCarType
     where person.id == id
     select carType).ToList();

```
Do like this because you are expecting multiple records to be returned:

```
 var result =   db.tblPeople
                  .Where(p => p.id == id)
                  .Select(s => s.tblCars
                  .SelectMany(z => z.tblCarType)).ToList();

```