Beispiel #1
0
        public static LargeValueObjectAsStruct[] Load(int size)
        {
            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand())
                {
                    var result = new LargeValueObjectAsStruct[size];

                    cmd.Connection  = conn;
                    cmd.CommandText = "select id,a,b,c,d,e,f,g,h FROM dbo.TestStructTable";

                    using (var reader = cmd.ExecuteReader())
                        while (reader.Read())
                        {
                            result[reader.GetInt32(0)] = new LargeValueObjectAsStruct(
                                reader.GetDouble(1),
                                reader.GetDouble(2),
                                reader.GetDouble(3),
                                reader.GetDouble(4),
                                reader.GetDouble(5),
                                reader.GetDouble(6),
                                reader.GetDouble(7),
                                reader.GetDouble(8));
                        }
                    return(result);
                }
            }
        }
Beispiel #2
0
        public static LargeValueObjectAsStruct[] PlayWithStruct(int size = 1000000)
        {
            var array = new LargeValueObjectAsStruct[size];

            for (var i = 1; i < array.Length; i++)
            {
                array[i] = new LargeValueObjectAsStruct(i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8);
            }
            var sum = 0.0;

            for (var i = 1; i < array.Length; i++)
            {
                sum += array[i].A;
                sum += array[i].B;
                sum += array[i].C;
                sum += array[i].D;
                sum += array[i].E;
                sum += array[i].F;
                sum += array[i].G;
                sum += array[i].H;
            }
            array[0] = new LargeValueObjectAsStruct(sum, 0, 0, 0, 0, 0, 0, 0);
            return(array);
        }