Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 28, 2012 07:20 AM by Decker Dong - MSFT
Member
5 Points
41 Posts
Nov 27, 2012 10:44 AM|LINK
Hi. I'm working with VS2012 .net 4.5 EF5
i want to use a join in a QueryCreated event, but i am not able to do it. I want that this code
protected void GridDataSource_QueryCreated(object sender, QueryCreatedEventArgs e) { DateTime _data = DateTime.Parse(TextBoxDataRegistroDiClasse.Text); int _idClasse = int.Parse(DropDownListClassi.SelectedItem.Value); var righe = e.Query.Cast<Registro_di_classe>(); e.Query = from riga in righe where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data select riga; }
Become
Segremat8Entities _segremat8=new Segremat8Entities(); DateTime _data = DateTime.Parse(TextBoxDataRegistroDiClasse.Text); int _idClasse = int.Parse(DropDownListClassi.SelectedItem.Value); var righe = e.Query.Cast<Registro_di_classe>(); e.Query = from riga in righe join classi in _segremat8.Classi on riga.ID_Classe_collegata equals classi.ID_Classi where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data select riga;
But it does't work. In what way i can use a Join in a QueryCreated event?
All-Star
118619 Points
18779 Posts
Nov 28, 2012 12:33 AM|LINK
Hello,
As far as I see, Occurs after the EntityDataSource creates an Entity SQL query that was specified during the configuration of the EntityDataSource control.
In fact you can see this sample:
http://msdn.microsoft.com/en-us/library/ee404748.aspx
Nov 28, 2012 07:04 AM|LINK
Yes I saw the sample, but i need to make a join for a where cause. Is it possible in some way?
Nov 28, 2012 07:08 AM|LINK
kuria but i need to make a join for a where cause. Is it possible in some way?
Where do you wanna add a "where"?
Nov 28, 2012 07:16 AM|LINK
e.Query = from riga in righe join classi in _segremat8.Classi on riga.ID_Classe_collegata equals classi.ID_Classi where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data && classi(JOINED TABLE).Name="name" select riga;
I want to make a where in the joined table value (or will join 6 tables and add a where in the table 6)
Nov 28, 2012 07:20 AM|LINK
If you wanna do something complicated, I think you can just remove EntityDataSource but manually do data-binding.
kuria
Member
5 Points
41 Posts
QueryCreated with join
Nov 27, 2012 10:44 AM|LINK
Hi. I'm working with VS2012 .net 4.5 EF5
i want to use a join in a QueryCreated event, but i am not able to do it.
I want that this code
protected void GridDataSource_QueryCreated(object sender, QueryCreatedEventArgs e) { DateTime _data = DateTime.Parse(TextBoxDataRegistroDiClasse.Text); int _idClasse = int.Parse(DropDownListClassi.SelectedItem.Value); var righe = e.Query.Cast<Registro_di_classe>(); e.Query = from riga in righe where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data select riga; }Become
Segremat8Entities _segremat8=new Segremat8Entities(); DateTime _data = DateTime.Parse(TextBoxDataRegistroDiClasse.Text); int _idClasse = int.Parse(DropDownListClassi.SelectedItem.Value); var righe = e.Query.Cast<Registro_di_classe>(); e.Query = from riga in righe join classi in _segremat8.Classi on riga.ID_Classe_collegata equals classi.ID_Classi where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data select riga;But it does't work. In what way i can use a Join in a QueryCreated event?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: QueryCreated with join
Nov 28, 2012 12:33 AM|LINK
Hello,
As far as I see, Occurs after the EntityDataSource creates an Entity SQL query that was specified during the configuration of the EntityDataSource control.
In fact you can see this sample:
http://msdn.microsoft.com/en-us/library/ee404748.aspx
kuria
Member
5 Points
41 Posts
Re: QueryCreated with join
Nov 28, 2012 07:04 AM|LINK
Yes I saw the sample, but i need to make a join for a where cause. Is it possible in some way?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: QueryCreated with join
Nov 28, 2012 07:08 AM|LINK
Where do you wanna add a "where"?
kuria
Member
5 Points
41 Posts
Re: QueryCreated with join
Nov 28, 2012 07:16 AM|LINK
e.Query = from riga in righe join classi in _segremat8.Classi on riga.ID_Classe_collegata equals classi.ID_Classi where riga.ID_Classe_collegata == _idClasse && riga.Data_registro_di_classe ==_data && classi(JOINED TABLE).Name="name" select riga;I want to make a where in the joined table value (or will join 6 tables and add a where in the table 6)
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: QueryCreated with join
Nov 28, 2012 07:20 AM|LINK
If you wanna do something complicated, I think you can just remove EntityDataSource but manually do data-binding.