select joined columns from joined tables using concat() like '%%' - c#

I was wondering if I could select values from joined tables
my tables are as following:
mysql> desc tblvitsign;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| vitsignid | int(11) | NO | PRI | NULL | |
| bp | varchar(30) | YES | | NULL | |
| bpstat | varchar(100) | YES | | NULL | |
| hr | varchar(30) | YES | | NULL | |
| hrstat | varchar(100) | YES | | NULL | |
| rr | varchar(30) | YES | | NULL | |
| rrstat | varchar(100) | YES | | NULL | |
| temp | varchar(30) | YES | | NULL | |
| tempstat | varchar(100) | YES | | NULL | |
| weight | varchar(50) | YES | | NULL | |
| height | varchar(30) | YES | | NULL | |
| bmi | varchar(30) | YES | | NULL | |
| bmistatus | varchar(30) | YES | | NULL | |
| patientid | int(11) | YES | MUL | NULL | |
| date | date | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
mysql> desc tblpatient;
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| patientid | int(11) | NO | PRI | NULL | |
| lastname | varchar(30) | YES | | NULL | |
| firstname | varchar(30) | YES | | NULL | |
| middlename | varchar(30) | YES | | NULL | |
| gender | varchar(15) | YES | | NULL | |
| birthday | date | YES | | NULL | |
| age | varchar(30) | YES | | NULL | |
+--------------+--------------+------+-----+---------+-------+
i joined them like so:
mysql> select a.lastname, a.firstname, a.middlename, b.bp, b.bpstat, b.hr, b.hrstat, b.rr, b.rrstat, b.temp, b.tempstat,
b.weight, b.height, b.bmi, b.bmistatus from tblpatient a left join
tblvitsign b on a.patientid = b.patientid;
+----------+-------------+------------+--------+--------+------+--------+------+--------+------+----------+--------+--------+-------+-----------+
| lastname | firstname | middlename | bp | bpstat | hr | hrstat | rr | rrstat | temp | tempstat | weight | height | bmi | bmistatus |
+----------+-------------+------------+--------+--------+------+--------+------+--------+------+----------+--------+--------+-------+-----------+
| Smith | Mark | Richards | 120/80 | Normal | 75 | Normal | 15 | Normal | 37 | Normal | 56 | 1.7 | 19.38 | Normal |
+----------+-------------+------------+--------+--------+------+--------+------+--------+------+----------+--------+--------+-------+-----------+
I am making a query for my search bar and I used this query using concat and like functions but it returns an empty set
mysql> select a.lastname, a.firstname, a.middlename, b.bp, b.bpstat,
b.hr, b.hrstat, b.rr, b.rrstat, b.temp, b.tempstat, b.weight,
b.height, b.bmi, b.bmistatus from tblpatient a left join tblvitsign b
on a.patientid = b.patientid where concat('a.lastname', 'a.firstname',
'a.middlename', 'b.bp', 'b.bpstat', 'b.hr', 'b.hrstat', 'b.rr',
'b.rrstat', 'b.temp', 'b.tempstat', 'b.weight', 'b.height', 'b.bmi',
'b.bmistatus') like '%ma%';
Empty set (0.14 sec)
is there a better way of doing this?

Related

How can I add different examples with different columns in specflow examples

The following code is my Scenario:
Scenario: TradeOrders
Given Order 'SellOrder' Has Been Registerd
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 0 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
And Order 'BuyOrder' Has Been Defined
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| <Buy> | <Price> | <Amount> | <IsFillAndKill> | <ExpireTime> |
When I Register The Order 'BuyOrder'
Then The following 'Trade' will be created
| BuyOrderId | SellOrderId | Amount | Price |
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
And BuyOrder 'BuyOrder' Should Be Modified like this
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 0 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
| 1 | 2 | 5 | 100 |
I want to add some examples with different columns but I have faced with below error:
Severity Code Description Project File Line Suppression State
Error Generation error: Message: The example sets must provide the
same parameters.
I appreciate you in advance.
This is not supported in SpecFlow. Since both tables are used in the same scenario, they need to go in the same row. It makes for a wide table, but there isn't anything you can do about it. Second of all, you cannot have < or > tokens in the column headers.
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime | BuyOrderId | SellOrderId | TradeAmount | TradePrice |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
You can also put spaces in the column headers so they are easier to read:
Examples:
| Buy | Price | Amount | Is Fill And Kill | Expire Time | Buy Order Id | Sell Order Id | Trade Amount | Trade Price |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
The choice to include spaces in column headers is subjective. It is supported to aid readability, but feel free to omit spaces if this does not make the examples table easier to understand.

Convert T-sql to Linq or Entityframework and not to use SqlQuery() for raw queries

I have a table which is called Signer :
+--------------+----------+---------+--------+--------------+---------+-----------+
| Name | User | Order | Signed | CompanyName | Status | InvoiceId |
+--------------+----------+---------+--------+--------------+---------+-----------+
| Anders | aa | 1 | 0 | OvnAnd2 | 0 | 26650 |
| Peyman | pm | 2 | 1 | OvnAnd2 | 1 | 26650 |
| Siw Ericsson | se | 3 | 0 | OvnAnd2 | 0 | 26650 |
| test | test | 4 | 0 | OvnAnd2 | 0 | 26650 |
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 26652 |
| test | test | 2 | 1 | OvnAnd2 | 0 | 26652 |
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 25365 |
+--------------+----------+---------+--------+--------------+---------+-----------+
Goal:
As you can see I have 3 different InvoiceId's. For each InvoiceId, I would like to find a row with minimum order number that Status column's value is 0 and User column has to be se.
( It means, Show the current users related invoices which are ready to be signed based on his/her username, order, signed columns)
I came up with this T-SQL which works fine :
select * from Signer s1
where s1.User = 'se' and Order = (select min(Order) from Signer s2 where s2.InvoiceId = s1.InvoiceId and Signed = 0)
And the result:
+--------------+----------+---------+--------+--------------+---------+-----------+
| Name | User | Order | Signed | CompanyName | Status | InvoiceId |
+--------------+----------+---------+--------+--------------+---------+-----------+
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 26652 |
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 25365 |
+--------------+----------+---------+--------+--------------+---------+-----------+
I would like to convert this query from T-Sql to Linq or EntityFramework :
This is my solution:
var temp = from x in db.Signers
where x.User == Me.UserName &&
x.Signed == 0
group x by x.InvoiceId
into item
select new
{
item.Key,
item = item.Min(x => x.Order)
};
Which returns 3 rows which is wrong because Siw should see the related invoices that are ready to be signed by her. (It means the first row should not be in the list)
+--------------+----------+---------+--------+--------------+---------+-----------+
| Name | User | Order | Signed | CompanyName | Status | InvoiceId |
+--------------+----------+---------+--------+--------------+---------+-----------+
| Anders | aa | 1 | 0 | OvnAnd2 | 0 | 26650 |
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 26652 |
|Siw Ericsson | se | 1 | 0 | OvnAnd2 | 0 | 25365 |
+--------------+----------+---------+--------+--------------+---------+-----------+
More info:
- As you can see in the first table, we have a special logic that someone can sign invoices out of order and Peyman is one of them.
- I don't want to use SqlQuery() method in Entityframework in order to execute t-sql queries.
I appreciate any help to find a solution for my goal.
Best regards
I think this is one of those situations where "let" come in handy:
var result = from s in Signers
let minToSign = Signers.Where(si =>
si.InvoiceId == s.InvoiceId && si.Signed == 0
).Min(si => si.Order)
where s.User == "se" && s.Order == minToSign
select s;

SQL Server : ADO.Net GetUpdateCommand ok with PK, fails after adding another clustered unique index

I have such a table with a non-clustered primary key:
CREATE TABLE [dbo].[StudentGrade](
[EnrollmentID] [int] IDENTITY(1,1) NOT NULL,
[CourseID] [nvarchar](10) NOT NULL,
[StudentID] [int] NOT NULL,
[Grade] [decimal](3, 2) NOT NULL,
CONSTRAINT [PK_StudentGrade] PRIMARY KEY NONCLUSTERED ([EnrollmentID] ASC))
The select statement is:
select EnrollmentID,Grade from StudentGrade
GetUpdateCommand works fine, the non-clustered primary key is recognized.
When adding another clustered unique index (on the both columns not even part of the select clause):
CREATE UNIQUE CLUSTERED INDEX [Badguy] ON [dbo].[StudentGrade] ([CourseID] ASC, [StudentID] ASC)
GetUpdateCommand fails with this exception:
System.InvalidOperationException: Dynamic SQL generation for the
UpdateCommand is not supported against a SelectCommand that does not return
any key column information.
If the index is not unique OR not clustered, there is no error.
It looks like the clustered unique index is preferred against the primary key for describing metadata. And if there are several key candidates (pk / unique index), it does not try to use the one having all columns in the query.
Is this an expected behaviour ? Any simple way to fix apart from selecting indexed columns or expliciting the update command ?
I need to have this clustered index for performance purposes, the primary key is not often used in queries.
It looks like the clustered unique index is preferred against the
primary key for describing metadata.
Yes, that's the crux of the issue. You can see this using sp_describe_first_result_set. With only the non-clustered primary key in place, the EnrolmentID column is the column identified as "is_part_of_unique_key":
EXEC sp_describe_first_result_set
#tsql = N'SELECT EnrollmentID,Grade FROM StudentGrade'
, #params = NULL
, #browse_information_mode = 1;
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| is_hidden | column_ordinal | name | is_nullable | system_type_id | system_type_name | max_length | precision | scale | collation_name | user_type_id | user_type_database | user_type_schema | user_type_name | assembly_qualified_type_name | xml_collection_id | xml_collection_database | xml_collection_schema | xml_collection_name | is_xml_document | is_case_sensitive | is_fixed_length_clr_type | source_server | source_database | source_schema | source_table | source_column | is_identity_column | is_part_of_unique_key | is_updateable | is_computed_column | is_sparse_column_set | ordinal_in_order_by_list | order_by_is_descending | order_by_list_length | tds_type_id | tds_length | tds_collation_id | tds_collation_sort_id |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| 0 | 1 | EnrollmentID | 0 | 56 | int | 4 | 10 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | EnrollmentID | 1 | 1 | 0 | 0 | 0 | NULL | NULL | NULL | 56 | 4 | NULL | NULL |
| 0 | 2 | Grade | 0 | 106 | decimal(3,2) | 5 | 3 | 2 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | Grade | 0 | 0 | 1 | 0 | 0 | NULL | NULL | NULL | 106 | 17 | NULL | NULL |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
After adding the unique clustered index on the composite natural key columns, CourseID and StudentID become the unique key preferred by client APIs. These are returned as hidden metadata columns flagged as "is_part_of_unique_key":
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+------------------------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| is_hidden | column_ordinal | name | is_nullable | system_type_id | system_type_name | max_length | precision | scale | collation_name | user_type_id | user_type_database | user_type_schema | user_type_name | assembly_qualified_type_name | xml_collection_id | xml_collection_database | xml_collection_schema | xml_collection_name | is_xml_document | is_case_sensitive | is_fixed_length_clr_type | source_server | source_database | source_schema | source_table | source_column | is_identity_column | is_part_of_unique_key | is_updateable | is_computed_column | is_sparse_column_set | ordinal_in_order_by_list | order_by_is_descending | order_by_list_length | tds_type_id | tds_length | tds_collation_id | tds_collation_sort_id |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+------------------------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| 0 | 1 | EnrollmentID | 0 | 56 | int | 4 | 10 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | EnrollmentID | 1 | 0 | 0 | 0 | 0 | NULL | NULL | NULL | 56 | 4 | NULL | NULL |
| 0 | 2 | Grade | 0 | 106 | decimal(3,2) | 5 | 3 | 2 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | Grade | 0 | 0 | 1 | 0 | 0 | NULL | NULL | NULL | 106 | 17 | NULL | NULL |
| 1 | 3 | CourseID | 0 | 231 | nvarchar(10) | 20 | 0 | 0 | SQL_Latin1_General_CP1_CI_AS | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | CourseID | 0 | 1 | 1 | 0 | 0 | NULL | NULL | NULL | 231 | 20 | 13632521 | 52 |
| 1 | 4 | StudentID | 0 | 56 | int | 4 | 10 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | StudentGrade | StudentID | 0 | 1 | 1 | 0 | 0 | NULL | NULL | NULL | 56 | 4 | NULL | NULL |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+------------------------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+--------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
The unique clustered index is preferred because that is the most efficient key to use for singleton queries. The implication is the client needs the key values returned by the SELECT query in order for auto-generated CRUD statements to function.
There are a couple of options to avoid adding the natural key columns to your select query. One method is to create view with the VIEW_METADATA option that encapsulates the query and use that in your code instead of the table directly:
CREATE VIEW vw_StudentGrade
WITH VIEW_METADATA
AS
SELECT EnrollmentID, Grade from StudentGrade;
The metadata is then limited to the columns returned by the view so the EnrollmentID is recognized as the unique key column even with the unique clustered index (or unique constraint) in place:
EXEC sp_describe_first_result_set
#tsql = N'SELECT EnrollmentID,Grade FROM vw_StudentGrade'
, #params = NULL
, #browse_information_mode = 1;
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+-----------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| is_hidden | column_ordinal | name | is_nullable | system_type_id | system_type_name | max_length | precision | scale | collation_name | user_type_id | user_type_database | user_type_schema | user_type_name | assembly_qualified_type_name | xml_collection_id | xml_collection_database | xml_collection_schema | xml_collection_name | is_xml_document | is_case_sensitive | is_fixed_length_clr_type | source_server | source_database | source_schema | source_table | source_column | is_identity_column | is_part_of_unique_key | is_updateable | is_computed_column | is_sparse_column_set | ordinal_in_order_by_list | order_by_is_descending | order_by_list_length | tds_type_id | tds_length | tds_collation_id | tds_collation_sort_id |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+-----------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
| 0 | 1 | EnrollmentID | 0 | 56 | int | 4 | 10 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | vw_StudentGrade | EnrollmentID | 1 | 1 | 0 | 0 | 0 | NULL | NULL | NULL | 56 | 4 | NULL | NULL |
| 0 | 2 | Grade | 0 | 106 | decimal(3,2) | 5 | 3 | 2 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | tempdb | dbo | vw_StudentGrade | Grade | 0 | 0 | 1 | 0 | 0 | NULL | NULL | NULL | 106 | 17 | NULL | NULL |
+-----------+----------------+--------------+-------------+----------------+------------------+------------+-----------+-------+----------------+--------------+--------------------+------------------+----------------+------------------------------+-------------------+-------------------------+-----------------------+---------------------+-----------------+-------------------+--------------------------+---------------+-----------------+---------------+-----------------+---------------+--------------------+-----------------------+---------------+--------------------+----------------------+--------------------------+------------------------+----------------------+-------------+------------+------------------+-----------------------+
The other option is to manually create the UpdateCommand instead of using CommandBuilder. That will give you full control so you can use EnrollmentID in the WHERE clause regardless of the metadata returned.

MySQL Query to retrieve data from two tables even no data found and unique column in both tables

I have two tables.
Menu
+----------------+----------------+
| menu_id | menu_desc |
+----------------+----------------+
| 1 | menu1 |
| 2 | menu2 |
| 3 | menu3 |
| 4 | menu4 |
| 5 | menu5 |
+----------------+----------------+
Rights
+----------+--------------+---------+
| Role_id | menu_id | Rights |
+----------+--------------+---------+
| 1 | 1 | 3 |
| 1 | 2 | 3 |
| 1 | 3 | 3 |
+----------+--------------+---------+
I want the output something like this,
+----------+------------------+------------+-----------+
| menu_id | menu_desc | Role_id | Rights |
+----------+------------------+------------+-----------+
| 1 | menu1 | 1 | 3 |
| 2 | menu2 | 1 | 3 |
| 3 | menu3 | 1 | 3 |
| 4 | menu4 | 1 | null |
| 5 | menu5 | 1 | null |
+----------+------------------+------------+-----------+
Is it possible?
This gives NULL for both Role_id and Rights
SELECT Menu.menu_id, Menu.menu_desc, Role.Role_id, Role.Rights
FROM Menu LEFT OUTER JOIN Role ON Menu.menu_id=Role.menu_id
ORDER BY Menu.menu_id
try below, if not getting required results then share problem:
SELECT m.menu_id, m.menu_desc, r.Role_id, r. Rights FROM Menu m LEFT JOIN `Rights` r ON m.menu_id=r.menu_id order by m.menu_id;
You have to use join:
select Menu.menu_id, menu_desc, Role_id, Rights.menu_id, Rights.Rights from Menu join Rights on Menu.menu_id=Rights.menu_id;

hierarchical navigation with conductor and event aggregator

This is my app architechture. Note that I have conductor as another conductor's child. And I have IHandle for each conductor to receive message from it's child.The message type is same as I use message just to navigating. My problem are I pass ShellView's EventAggregator to it's children.
How about NewConnectionView's EventAggregator ? Since I use it's EventAggregator for navigating on ShellView. And for it's children to navigating on it's ActiveItem.
How to separate these 2 EventAggregators in one ViewModel.
ShellView & NewConnectionView ==> Conductor.Collection.OneActive
+----------------------------------+
| ShellView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| NewConnectionView |_|[]|x| | ConnectionListView |_|[]|x|
+----------------------------------+ +----------------------------------+
| +------------------------------+ | | TextBlock |
| | ComboBox | V | | | +----------------------+ +-----+ |
| +------------------------------+ | | | | | Btn | |
| +------------------------------+ | | | | +-----+ |
| | | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | DataGrid | +-----+ |
| | ActiveItem | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | |
| +------------------------------+ | | +----------------------+ |
+----------------------------------+ +----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| FileConnectionView |_|[]|x| | DatabaseConnectionView |_|[]|x|
+----------------------------------+ +----------------------------------+
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+----------------------------------+ +----------------------------------+
Currently, my approach is using NewConnectionShellView (Screen) as NewConnectionView's (Conductor) parent to separate the EventAggregator. But the problem is, I can't get DisplayName of the NewConnectionView's children to display into my Main Window (ShellView).
Please note that I'm not using MEF. Is there any workaround for my problem ?
+----------------------------------+
| ShellView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| NewConnectionShellView |_|[]|x| | ConnectionListView |_|[]|x|
+----------------------------------+ +----------------------------------+
| +------------------------------+ | | TextBlock |
| | | | | +----------------------+ +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | DataGrid | +-----+ |
| | ActiveItem | | | | | +-----+ |
| | | | | | | | Btn | |
| | | | | | | +-----+ |
| | | | | | | |
| +------------------------------+ | | +----------------------+ |
+----------------------------------+ +----------------------------------+
|
|
|
|
|
|
|
|
V
+----------------------------------+
| NewConnectionView |_|[]|x|
+----------------------------------+
| +------------------------------+ |
| | ComboBox | V | |
| +------------------------------+ |
| +------------------------------+ |
| | | |
| | | |
| | | |
| | ActiveItem | |
| | | |
| | | |
| | | |
| +------------------------------+ |
+----------------------------------+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+----------------------------------+ +----------------------------------+
| FileConnectionView |_|[]|x| | DatabaseConnectionView |_|[]|x|
+----------------------------------+ +----------------------------------+
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+----------------------------------+ +----------------------------------+
It sounds like you want to use one instance of the event aggregator for shell/plugin communication, and one instance per plugin for inter-view model communication. I would recommend using both an IoC container and register the shell event aggregator as a singleton, and then using factories which have a reference to the container to resolve instances of your view models.
You could have one message type which changes the display name and is published on the instance of the shell view event aggregator, and one message type which changes the current active item and is used on all event aggregator instances.

Categories

Resources