Hi there,
I got 2 EF Code first tables
public
class
ActionGES
{
public
int
ActionGESID {
get
;
set
; }
[MaxLength(250)]
public
string
TitreAL {
get
;
set
; }
[Required]
public
string
Description {
get
;
set
; }
//FK
public
ICollection<IndicateurAction> Indicateurs {
get
;
set
; }
}
public
class
IndicateurAction
{
public
int
IndicateurActionID {
get
;
set
; }
[Required]
public
int
Indicateur {
get
;
set
; }
[Required]
public
int
Annee {
get
;
set
; }
public
bool
ApprouveEA {
get
;
set
; }
//FK Key
public
int
ActionGESId {
get
;
set
; }
[ScriptIgnore]
public
ActionGES ActionGES {
get
;
set
; }
}
work good with LINQ with .include
My question is: it is normal that when I call Destroy on my grid, I ActionGES object are created in the controller action with FK Indicateurs collection count = 1 but with en [0] item = null...
My Controller action
//POST: Actions_Destroy
[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Actions_Destroy([DataSourceRequest] DataSourceRequest request, ActionGES act)
{
if
(act !=
null
&& ModelState.IsValid)
{
this
.actionService.DeleteAction(act);
}
return
Json(
new
[] { act }.ToDataSourceResult(request, ModelState));
}
The "act" variable contain a Indicator with a null item. Look the picture.