Combine fields from two tables into one autocompletebox - entity-framework

I have two tables "Services and Projects". Both tables have a "Name" field. I would like to take both fields from both the tables and put them into a single autocompletebox in one of my screens. I searched around and found different methods of doing this but not in LightSwitch. Any ideas?

If I understand your requirement correctly, you want the Name property from both Services and Projects to appear in a single textbox? If this is the case, my approach would be as follows:
Use a view on the data source to union the Projects and Services data sources
Add that view to your data model (on a new data connection)
Define Name as the summary property for the new view-based entity.
Add the view to your screen as a separate query
Add the view data object to your screen as an auto-complete box.
WARNING: You'll also need code-behind to identify whether the value selected is a Project or a Service and to apply this value to the relevant field in your linked entity.

Related

Symfony2: Collection of dropdown select lists for a many-to-many relationship

The objective:
Having a many-to-many relation be displayed as a dynamic list of select inputs(single choice dropdown list)
User arrives on page with a single select field (multiple = false) populated with persisted entities and add/remove buttons. By clicking the add button, a new select field with the same options appears below the first, which adds a new entry in the M2M relation. By clicking remove the field disappears and the entry should be removed.
The model:
Two entities: User & Manager. A User has exactly one "special" Manager and unlimited normal Managers.
Managers manage unlimited users.To model this I have created two relationships for which the user is the "owner" (not sure how to translate this)
ManyToOne specialManager
ManyToMany normalManagers
I haven't created a many to many relationship with attribute "special" because the requirement is exactly one special manager and I wasn't sure if Symfony/Doctrine would cause problems down the line.
What I have:
I can display a multiple select field with the existing entities using Entity field type, as per the documentation. Functionally this is what I need, visually it is not.
I can also use the Collection field type to display a single text field, and add or remove more with JS, as per the documentation. Visually this is what I need, but The text fields (entity attribute) need to be replaced by choice field.
The question:
Before I continue digging, is there a simple way to achieve this list of select tags?
For anyone else who may eventually need a dynamic list of select fields:
I initially solved this issue by detaching the field(s) in event listeners, and handling the display/submission manually in the controller.
However I wasn't satisfied with this clunky solution and when I encountered the same need I used a second solution: creating an intermediary entity xxxChoice (in this case ManagerChoice) which is Mto1 inversed related to User and Mto1 related to Manager. Then by creating a ManagerChoiceType form with "Manager" entity field type I was able to easily display my collection of dropdown select lists.

EMF-Edit: visualizing the object referencing an object?

I created a EMF ecore model that could look like this:
The model contains a list of Family
The model contains a list of VisitedCountry
A Family contains a list of Individual
A VisitedCountry contains a list of references to some Individuals
after the plugins EMF-Edit and EMF-Editor have been generated and when I run the generated GUI: when I click an Indvidual, is there a way to display a table listing all his VisitedCountry ?
To easily do that, you could add a non-containment reference from Individual to VisitedCountry, which must be an opposite reference (EOpposite) to the reference you defined from VisitedCountry to Individual.
Doing that, you could check when selecting an Individual when editing your model with the generated model editor, you can access their VisitedCountry in the Properties View. In general defining EOpposite references beetween classes is always useful for other puposes, since you have bidirectional navigation between both classes.

How do I get the column name from an Entity Framework Association

I have an entity model built using the designer. In one of my tables (application), I have several foreign keys that reference the same status (status) table. As a result, when my associations were built, I have several entity objects built with an auto indexing name:
application_statuses2
application_statuses3
etc.
I'm building a "version history" type screen and want to be able to properly list the "friendly name" for each column modified. For example, I want to display "Destination Status" will be displayed instead of "application_statuses2". If I can determine the endpoint column name on the association in question, I can setup the proper display value.
I can find the entity object in the designer, I can even track where it references the foreign key in question that built the association, but I can seem to find the property that outlines the enpoints or column names. How do I determine the column name, or endpoint, on my association, or entity?
I wish it were more ready to hand, have been looking for it as well. Bit of a pain when you have multiple FKs to the same table.
Click on the navigation property you want to check
Under properties, look at the name of the association
At the top of properties, use the object navigator dropdown to switch to the association
Click into the 'Referential Constraint' property
Use the ellipses button on the right to bring up the column names
Dont know if there is a better way of doing this, but I certainly hope so!

How to bind multiple tables to a binding navigator using data source wizard in C#

How to bind multiple tables to a binding navigator using data source wizard in C# so that when textbox1 value changes the values in other textboxes should be change which contains data from other table. tables have foreign key relationships.
The BindingNavigator should have a BindingSource value set to the BindingSource object of your "parent" or "master" table in the dataset (same as textBox1). The "other table" controls should have a BindingSource object that points to the "child" datatables. If your relationships are properly setup then when you change the master/parent record with the bindingnavigator then the detail/child records will update accordingly
Basically, the binding source for your "other tables" should have a DataSource value pointing to the BindingSource of your primary table (the binding source of textbox1) and
should have a DataMember value of the relationship/FK that points to the respective secondary table.
If you are using drag and drop datasources then be sure you are dragging over the data sources that utilize the relationships. So say you created a dataset with 3 tables with tiered relationships: Grandparent, Parent, Child. In your Data Sources window you will see all three datatables side by side. You are probably dragging the desired Grandparent field over and getting your binding navigator, binding source, and textbox created, correct? You might think you are supposed to then use those side-by-side root-level Parent and Child datasources but that is WRONG. Expand the Grandparent source and at the end of columns listed you will see Parent listed again nested underneath Grandparent. Expand that and use those columns. At the bottom of that nested Parent you will see a Child data source that you can expand and use columns from.

ASP.NET Dynamic Data : How to Specify Sort Order of Items in Dropdown List

I am using ASP.NET dynamic data for the data adminstration tasks for a Silverlight app that I built. It saved a ton of time not having to write all of the admin screens you typically have to create for end users to manage the data.
One thing I cannot figure out how to sort the items in the drop downs that appear on the screens - either the filter dropdowns on the list views or on the data entry screens.
Do I specify that somewhere in the EDM partial classes or in the ASP.NET DD field templates? or somewhere else?
All I need to do is sort alphabetically by the display value- they appear to be in random order.
thanks
Michael
Use the DisplayColumn Attribute in the System.ComponentModel.DataAnnotations Namespace.
http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx
ex:
[DisplayColumn("LastName", "LastName")]
public partial class Employee
{
}
The answer to your question can be found here, about halfway down the page:
http://csharpbits.notaclue.net/2008/08/dynamic-data-and-field-templates-second.html
In the Cascase.ascx.cd FilterControl and Cascade_Edit.ascx.cs FieldTemplate you will find a method GetChildListFilteredByParent. This returns the values for the filtered DropDownList, but as you will see this list is an unordered list. To add sorting to this list we need to add a Linq OrderBy clause.