New Posts New Posts RSS Feed: Binding Objects
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Binding Objects

 Post Reply Post Reply
Author
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Topic: Binding Objects
    Posted: 04-Nov-2008 at 10:09am
I'm converting a DevForce classic application to DevForceEF. I'm new to the EF, Link, and DevForceEF so I'm having a problem understanding the upgrade and converting the code. For example here is some of my code:
 
private EntityList<LuActionType> mLuActionType;
private BindingList<Employee> mEmployeesBlank;
private EntityList<Employee> mEmployeesFilter;
private EntityList<Employee> mEmployees;
 
I've included the following references:
using IdeaBlade.EntityModel.v4;
using IdeaBlade.Util;
using DomainModel;
So, when declaring objects now it looks like I now have a choice of using a BindableList or BindingList. So, what is the difference and which one should I use?
 
USING A PASSTHRU. Here is my old code:
//-- using a passthru query
PassthruRdbQuery query = Employee.GetEmpoyeeDobByMonth(_currentmo.ToString());
query.QueryStrategy = QueryStrategy.DataSourceOnly;
mEmployees = mPersMgr.GetEntities<Employee>(query);
bsEmployee.DataSource = mEmployees;
 
I've now changed the bold line to:
mEmployees = (BindableList<Employee>) mPersMgr.ExecuteQuery(query);
 
Is this correct? It's the only way I could get it to compile because the BindableList isn't compatible with IEnumerable, I think.
 
USING A FILTER/PREDICATE
I've tried the following:
 
var filterCurrentEmployees = new Predicate<Employee>(delegate(Employee anEmployee) {
 return anEmployee.Status.StatusCode  == "C";
});
     
mEmployeesFilter.AddRange(mEmployees);
mEmployeesFilter.ListManager = new EntityListManager<Employee>(mPersMgr, filterCurrentEmployees, null);
 
BUT now I get an incompatibility with the EntityListManager and the ListManager!
 
I've looked through the examples and the developers guide but neither give me a full picture of how to do the conversions, nor do the uses of objects seem consistent between the examples. Any help would be appreciated.
 
 
puctx
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 05-Nov-2008 at 2:55pm
Originally posted by pucsoftware

So, when declaring objects now it looks like I now have a choice of using a BindableList or BindingList. So, what is the difference and which one should I use?
 
 
Use the BindableList<T> if you're developing a user interface with Winforms and want to use DevForce data binding and the DevForce UI components and designers.
 
 
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 05-Nov-2008 at 2:57pm

Originally posted by pucsoftware


I've now changed the bold line to:
mEmployees = (BindableList<Employee>) mPersMgr.ExecuteQuery(query);
Is this correct? It's the only way I could get it to compile because the BindableList isn't compatible with IEnumerable, I think.

 
In general you should use
 
     mEmployees.ReplaceRange(IEnumerable<T> pValues)
 
to populate a BindableList.  What you did above replaces existing mEmployees with a new one, and therefore breaks any linkages you've already configured.  Specifically, if you say
 
    BindableList<Employee> mEmployees = new BindableList<Employee>();
    BindingSource mEmployeesBS = new BindingSource();
    mEmployeesBS.DataSource = mEmployees;
    mEmployees = any other BindableList returned by any method call
 
then the link between mEmployees and mEmployeesBS gets broken.  But if your last line was
 
     mEmployees.ReplaceRange( any IEnumerable<Employee> )
 
that link is not broken.

(FYI, all of the above applies equally to V3, except there you'd likely be using EntityLists rather than BindableLists.)
 
 

Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 05-Nov-2008 at 3:15pm
Originally posted by pucsoftware

I've tried the following:
 
var filterCurrentEmployees = new Predicate<Employee>(delegate(Employee anEmployee) {
 return anEmployee.Status.StatusCode  == "C";
});
     
mEmployeesFilter.AddRange(mEmployees);
mEmployeesFilter.ListManager = new EntityListManager<Employee>(mPersMgr, filterCurrentEmployees, null);
 
BUT now I get an incompatibility with the EntityListManager and the ListManager!
 
You now need to configure the link between the manager from the other direction:
 
    EntityListManager<Employee> elm = new EntityListManager<Employee>(mPersMgr, filterCurrentEmployees, null);
   elm.ManageList(mEmployeesFilter, true);
 
 
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 06-Nov-2008 at 7:47am
Thanks for all the suggestions. Well explained and really helped to clear a couple of things up. I did get the application to compile. With these comments I can go back and refine the code with a better understanding of what I'm doing. Again, thanks for the help.
 
 
puctx
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 07-Nov-2008 at 10:32pm
Happy to be of assistance!
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 04-Mar-2009 at 12:25pm
Is there a reason that BindableList is now declared as Friend instead of Public in IdeaBlade.Util.v4 ?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 04-Mar-2009 at 2:22pm
The BindableList included with DevForce EF is intended for legacy support within DevForce and not outside use.  You can still use the IdeaBlade.Util.BindableList from DevForce Classic in your DevForce EF WinForms applications.  Several of the tutorials, including "Configuring a WinForm" from the 100 Fundamentals series, show how to use both DevForce EF and Classic in the same application.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 04-Mar-2009 at 2:54pm
Thanks! Must have skipped that small step! :)
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 31-Mar-2009 at 1:23pm
Regarding: "The BindableList included with DevForce EF is intended for legacy support"
 
What object would I use that is not a legacy object but would provide similar funtionality? Or is there a different way to do this entirely? I'm starting all over on my project since I've been away from it for a while so I have no legacy requirements at this time and I've only installed the EF version of DevForce. I'd like to start off correctly using only an EF design.
 
The code I'm converting:
 
/// <summary>Get Employees from Department</summary>
public BindableList<Employee> DivisionDepartments {
get {
 BindableList<Employee> mList = new BindableList<Employee>();
 mList.AddRange(this.Employees);
 return mList;
 }
}
 
I'm a little confused because when I created a new project IdeaBlade.Util was not included as a reference, but it looks like this assembly, as well as the BindableList object, is used extensively in all the examples I've looked at.
puctx
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2009 at 6:16pm
The BindableList is still important if you're doing a Winforms user interface and want to take advantage of DevForce's WinForm support (BindingManagers, etc.)

If you're doing WPF or Silverlight, the System.Collections.ObjectModel.ObservableCollection<T> (part of .NET) offers similar functionality.
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 03-Apr-2009 at 7:14am
Thanks for the response. The System.Collections.ObjectModel.ObservableCollection is new to me so I'll check it out. But, I am doing WinForms. You mentioned if I "want to take advanatage of the DevForce BindingManagers". I have in a couple of instances (using the DevExpress Lookup Grid control) not used the BindingManager and everything seemed to work fine. Is the DevForce BindingManager purely optional? Are there any disadvantages/pitfalls when not using the BindingManager?
 
Again, thanks for you input.
 
Darren 
puctx
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down