質問するログイン新規登録

質問編集履歴

15

関連するタグの追加

2016/03/11 00:02

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
File without changes

14

{}の閉じがうまくできていなかったため修正

2016/03/11 00:02

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -155,10 +155,9 @@
155
155
  // 個人履歴に追加
156
156
  addcol.AddRange(col);
157
157
  ++i_c;
158
- }
159
158
 
160
- foreach (var his in addcol)
159
+ foreach (var his in col)
161
- {
160
+ {
162
161
  var hist = new History(target);
163
162
  hist.Name = target.name;
164
163
  hist.Team = his.team;
@@ -166,14 +165,13 @@
166
165
  hist.Start = his.start;
167
166
  hist.End = his.end;
168
167
  target.Histories.Add(hist);
168
+ }
169
+ target.ColStartPos = cols;
170
+ cols += target.OutputWidth() + 1;
169
171
  }
170
- target.ColStartPos = cols;
171
- cols += target.OutputWidth() + 1;
172
-
173
172
  }
174
173
  }
175
174
  }
176
-
177
175
  ```
178
176
 
179
177
  ###補足情報

13

{}の閉じがうまくできていなかったため修正

2016/03/10 08:13

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -155,9 +155,10 @@
155
155
  // 個人履歴に追加
156
156
  addcol.AddRange(col);
157
157
  ++i_c;
158
+ }
158
159
 
159
- foreach (var his in addcol)
160
+ foreach (var his in addcol)
160
- {
161
+ {
161
162
  var hist = new History(target);
162
163
  hist.Name = target.name;
163
164
  hist.Team = his.team;
@@ -165,13 +166,14 @@
165
166
  hist.Start = his.start;
166
167
  hist.End = his.end;
167
168
  target.Histories.Add(hist);
168
- }
169
- target.ColStartPos = cols;
170
- cols += target.OutputWidth() + 1;
171
169
  }
170
+ target.ColStartPos = cols;
171
+ cols += target.OutputWidth() + 1;
172
+
172
173
  }
173
174
  }
174
175
  }
176
+
175
177
  ```
176
178
 
177
179
  ###補足情報

12

コメントを変更途中で更新してしまったため追加

2016/03/10 08:12

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -198,7 +198,7 @@
198
198
  {T1, P02, 2013-8-21, 2013-12-20},
199
199
  {T1, P03, 2014-1-11, 2014-3-30}
200
200
  };
201
- // 2回目(addcolは上書きするため、colの内容を
201
+ // 2回目(addcolは毎回上書きする)
202
202
  addcol =
203
203
  {
204
204
  {T2, P01, 2014-5-1, 2014-8-10},
@@ -209,7 +209,7 @@
209
209
  {
210
210
  {T3, P09, 2015-4-11, 2015-12-30}
211
211
  };
212
- // 合算後
212
+ // 合算後(addcolを3回目まで足しこむ)
213
213
  col =
214
214
  {
215
215
  {T1, P01, 2013-5-1, 2013-8-10},

11

今更ですが個人履歴のLINQが間違っていたため修正

2016/03/10 05:42

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -146,10 +146,9 @@
146
146
 
147
147
  // TEAM毎の個人履歴をセット
148
148
  var addcol = from a in DbContext.TEAM_HIS
149
- where (a.team == forlist.team
149
+ where a.team == forlist.team
150
- && a.start < next)
150
+ && a.start < next
151
- || (a.team == forlist.team
152
- && a.start >= next)
151
+ && a.start >= start
153
152
  && a.start < loss
154
153
  orderby a.start ascending
155
154
  select a;
@@ -192,14 +191,14 @@
192
191
  AddRangeをどう利用したいかですが、
193
192
 
194
193
  ```C#
195
- // 1回目
194
+ // 1回目(本当はこれはaddcolではなく、colの形が望ましい)
196
195
  addcol =
197
196
  {
198
197
  {T1, P01, 2013-5-1, 2013-8-10},
199
198
  {T1, P02, 2013-8-21, 2013-12-20},
200
199
  {T1, P03, 2014-1-11, 2014-3-30}
201
200
  };
202
- // 2回目
201
+ // 2回目(addcolは上書きするため、colの内容を
203
202
  addcol =
204
203
  {
205
204
  {T2, P01, 2014-5-1, 2014-8-10},
@@ -216,7 +215,7 @@
216
215
  {T1, P01, 2013-5-1, 2013-8-10},
217
216
  {T1, P02, 2013-8-21, 2013-12-20},
218
217
  {T1, P03, 2014-1-11, 2014-3-30},
219
- {T2, P01, 2014-5-1, 2014-8-10},
218
+ {T2, P04, 2014-5-1, 2014-8-10},
220
219
  {T2, P08, 2014-8-21, 2015-3-30},
221
220
  {T3, P09, 2015-4-11, 2015-12-30}
222
221
  };

10

,漏れを追記

2016/03/10 05:39

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -202,10 +202,10 @@
202
202
  // 2回目
203
203
  addcol =
204
204
  {
205
- {T2, P01, 2014-5-1, 2014-8-10}
205
+ {T2, P01, 2014-5-1, 2014-8-10},
206
206
  {T2, P08, 2014-8-21, 2015-3-30}
207
207
  };
208
- // 3回目
208
+ // 3回目
209
209
  addcol =
210
210
  {
211
211
  {T3, P09, 2015-4-11, 2015-12-30}
@@ -213,11 +213,11 @@
213
213
  // 合算後
214
214
  col =
215
215
  {
216
- {T1, P01, 2013-5-1, 2013-8-10}
216
+ {T1, P01, 2013-5-1, 2013-8-10},
217
- {T1, P02, 2013-8-21, 2013-12-20}
217
+ {T1, P02, 2013-8-21, 2013-12-20},
218
- {T1, P03, 2014-1-11, 2014-3-30}
218
+ {T1, P03, 2014-1-11, 2014-3-30},
219
- {T2, P01, 2014-5-1, 2014-8-10}
219
+ {T2, P01, 2014-5-1, 2014-8-10},
220
- {T2, P08, 2014-8-21, 2015-3-30}
220
+ {T2, P08, 2014-8-21, 2015-3-30},
221
221
  {T3, P09, 2015-4-11, 2015-12-30}
222
222
  };
223
223
 

9

コメントを調整

2016/03/10 01:29

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -192,25 +192,26 @@
192
192
  AddRangeをどう利用したいかですが、
193
193
 
194
194
  ```C#
195
- addcol = // 1回目
195
+ // 1回目
196
+ addcol =
196
197
  {
197
198
  {T1, P01, 2013-5-1, 2013-8-10},
198
199
  {T1, P02, 2013-8-21, 2013-12-20},
199
200
  {T1, P03, 2014-1-11, 2014-3-30}
200
201
  };
201
-
202
- addcol = // 2回目
202
+ // 2回目
203
+ addcol =
203
204
  {
204
205
  {T2, P01, 2014-5-1, 2014-8-10}
205
206
  {T2, P08, 2014-8-21, 2015-3-30}
206
207
  };
207
-
208
- addcol = // 2回目
208
+ // 3回目
209
+ addcol =
209
210
  {
210
211
  {T3, P09, 2015-4-11, 2015-12-30}
211
212
  };
212
-
213
- col = // 合算後
213
+ // 合算後
214
+ col =
214
215
  {
215
216
  {T1, P01, 2013-5-1, 2013-8-10}
216
217
  {T1, P02, 2013-8-21, 2013-12-20}

8

記入漏れを追加

2016/03/10 01:25

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -208,7 +208,7 @@
208
208
  addcol = // 2回目
209
209
  {
210
210
  {T3, P09, 2015-4-11, 2015-12-30}
211
- }
211
+ };
212
212
 
213
213
  col = // 合算後
214
214
  {
@@ -218,7 +218,7 @@
218
218
  {T2, P01, 2014-5-1, 2014-8-10}
219
219
  {T2, P08, 2014-8-21, 2015-3-30}
220
220
  {T3, P09, 2015-4-11, 2015-12-30}
221
- }
221
+ };
222
222
 
223
223
  ```
224
224
  上記のような2次元配列を足しこんでいくようにしていきたいです。

7

AddRangeをどう利用したいか

2016/03/10 01:13

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -188,5 +188,40 @@
188
188
  エラー自体の意味が理解できていなく、可能でありましたらエラーの意味と解決方法を教えていただけますでしょうか。
189
189
  よろしくお願いいたします。
190
190
 
191
+ ###補足2
192
+ AddRangeをどう利用したいかですが、
193
+
194
+ ```C#
195
+ addcol = // 1回目
196
+ {
197
+ {T1, P01, 2013-5-1, 2013-8-10},
198
+ {T1, P02, 2013-8-21, 2013-12-20},
199
+ {T1, P03, 2014-1-11, 2014-3-30}
200
+ };
201
+
202
+ addcol = // 2回目
203
+ {
204
+ {T2, P01, 2014-5-1, 2014-8-10}
205
+ {T2, P08, 2014-8-21, 2015-3-30}
206
+ };
207
+
208
+ addcol = // 2回目
209
+ {
210
+ {T3, P09, 2015-4-11, 2015-12-30}
211
+ }
212
+
213
+ col = // 合算後
214
+ {
215
+ {T1, P01, 2013-5-1, 2013-8-10}
216
+ {T1, P02, 2013-8-21, 2013-12-20}
217
+ {T1, P03, 2014-1-11, 2014-3-30}
218
+ {T2, P01, 2014-5-1, 2014-8-10}
219
+ {T2, P08, 2014-8-21, 2015-3-30}
220
+ {T3, P09, 2015-4-11, 2015-12-30}
221
+ }
222
+
223
+ ```
224
+ 上記のような2次元配列を足しこんでいくようにしていきたいです。
225
+
191
226
  ※2つのテーブルと出力結果をアップローダーにあげておきます。
192
227
  [リンク内容](http://www.dotup.org/uploda/www.dotup.org771351.xlsx.html)

6

スペルミスを調整

2016/03/10 01:12

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -167,8 +167,8 @@
167
167
  hist.End = his.end;
168
168
  target.Histories.Add(hist);
169
169
  }
170
- target.ColStartPos = col;
170
+ target.ColStartPos = cols;
171
- col += target.OutputWidth() + 1;
171
+ cols += target.OutputWidth() + 1;
172
172
  }
173
173
  }
174
174
  }

5

カラム位置に関係する出力用のデータのコレクションをソースに追記

2016/03/09 23:58

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -157,6 +157,18 @@
157
157
  addcol.AddRange(col);
158
158
  ++i_c;
159
159
 
160
+ foreach (var his in addcol)
161
+ {
162
+ var hist = new History(target);
163
+ hist.Name = target.name;
164
+ hist.Team = his.team;
165
+ hist.Project = his.project;
166
+ hist.Start = his.start;
167
+ hist.End = his.end;
168
+ target.Histories.Add(hist);
169
+ }
170
+ target.ColStartPos = col;
171
+ col += target.OutputWidth() + 1;
160
172
  }
161
173
  }
162
174
  }

4

TEAM_HISのDbSetを追加

2016/03/09 07:54

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,30 @@
11
11
 
12
12
  ###ソースコード
13
13
  ```C#
14
+ namespace A.Models
15
+ {
16
+ using System;
17
+ using System.Data.Entity;
18
+ using System.ComponentModel.DataAnnotations.Schema;
19
+ using System.Linq;
14
20
 
21
+ public partial class DefaultContext : DbContext
22
+ {
23
+ public DefaultContext()
24
+ : base("name=DefaultContext")
25
+ {
26
+ }
27
+ /// <summary>
28
+ /// プロジェクト経歴
29
+ /// </summary>
30
+ public virtual DbSet<TEAM_HIS> TEAM_HIS { get; set; }
31
+ /// <summary>
32
+ /// 変更履歴
33
+ /// </summary>
34
+ public virtual DbSet<CHANGE_HIS> CHANGE_HIS { get; set; }
35
+ }
36
+ }
37
+
15
38
  namespace A.Models
16
39
  {
17
40
  using System;

3

質問の文言を修正

2016/03/09 06:14

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -150,7 +150,7 @@
150
150
  このような観点でプログラムを作成しています。
151
151
 
152
152
  ところが、AddRangeを使用すると、表記のエラーが出てしまい解決できませんでした。
153
- エラー自体の意味が理解できていないので、解決方法を教えていただけると助かります。
153
+ エラー自体の意味が理解できていな可能でありましたらエラーの意味と解決方法を教えていただけますでしょうか
154
154
  よろしくお願いいたします。
155
155
 
156
156
  ※2つのテーブルと出力結果をアップローダーにあげておきます。

2

内容を微調整

2016/03/09 02:50

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -24,13 +24,13 @@
24
24
  {
25
25
  [Key]
26
26
  [Column(Order = 0)]
27
- [StringLength(14)]
27
+ [StringLength(10)]
28
28
  [DisplayName("team名")]
29
29
  public string team { get; set; }
30
30
 
31
31
  [Key]
32
32
  [Column(Order = 1)]
33
- [StringLength(2)]
33
+ [StringLength(10)]
34
34
  [DisplayName("プロジェクト")]
35
35
  public string project { get; set; }
36
36
 

1

team_HISのソースコードを追加

2016/03/09 02:48

投稿

FitD
FitD

スコア40

title CHANGED
File without changes
body CHANGED
@@ -11,6 +11,43 @@
11
11
 
12
12
  ###ソースコード
13
13
  ```C#
14
+
15
+ namespace A.Models
16
+ {
17
+ using System;
18
+ using System.Collections.Generic;
19
+ using System.ComponentModel;
20
+ using System.ComponentModel.DataAnnotations;
21
+ using System.ComponentModel.DataAnnotations.Schema;
22
+ using System.Data.Entity.Spatial;
23
+ public partial class TEAM_HIS
24
+ {
25
+ [Key]
26
+ [Column(Order = 0)]
27
+ [StringLength(14)]
28
+ [DisplayName("team名")]
29
+ public string team { get; set; }
30
+
31
+ [Key]
32
+ [Column(Order = 1)]
33
+ [StringLength(2)]
34
+ [DisplayName("プロジェクト")]
35
+ public string project { get; set; }
36
+
37
+ [Key]
38
+ [Column(Order = 2)]
39
+ [DisplayName("開始日時")]
40
+ public DateTime start { get; set; }
41
+
42
+ [Key]
43
+ [Column(Order = 3)]
44
+ [DisplayName("終了日時")]
45
+ public DateTime end { get; set; }
46
+ }
47
+ }
48
+
49
+
50
+
14
51
  using System;
15
52
  using System.Collections.Generic;
16
53
  using System.Linq;