Preface is not nonsense, directly into the application of the scene
EF version: 6+
MySQL version: 5+
Action Step 1
CREATE table 2 in MySQL, Testweigh and Testordership, respectively. The table script looks like this:
SET foreign_key_checks=0;
-- ----------------------------
--Table structure for ' Testweigh '
-- ----------------------------
DROP TABLE IF EXISTS ' Testweigh ';
CREATE TABLE ' Testweigh ' (
' Logisticsno ' varchar (not NULL),
PRIMARY KEY (' Logisticsno ')
) Engine=innodb DEFAULT Charset=utf8;
-- ----------------------------
--Records of Testweigh
-- ----------------------------
INSERT into ' Testweigh ' VALUES (' FF271237513CN ');
And
SET foreign_key_checks=0;
-- ----------------------------
--Table structure for ' testordership '
-- ----------------------------
DROP TABLE IF EXISTS ' testordership ';
CREATE TABLE ' testordership ' (
' Shopcode ' varchar (not NULL DEFAULT ' '),
' Billno ' varchar (not NULL DEFAULT ' '),
' Logisticsno ' varchar DEFAULT NULL,
PRIMARY KEY (' Shopcode ', ' Billno ')
) Engine=innodb DEFAULT Charset=utf8;
-- ----------------------------
--Records of Testordership
-- ----------------------------
INSERT into ' testordership ' VALUES (' Default ', ' 64909520666335 ', ' FF271237513CN ');
INSERT into ' testordership ' VALUES (' Default ', ' 64909520777335 ', ' FF271237513CN ');
INSERT into ' testordership ' VALUES (' Default ', ' 64909520888335 ', ' FF271237513CN ');
Step 2
To create the view 1, the view script looks like this:
CREATE VIEW Vtestorderweigh
As
Select W.logisticsno,s.shopcode,s.billno from Testweigh W left joins testordership s on w.logisticsno = S.logisticsno;
Step 3
Execute the view query to get the following result:
Step 4
L Create EF entity classes
L Get data from EF
here's the problem. ? Why is the three-piece data Billno values are the same ? in Query view , the values should be 666,777,888
Ef+mysql use problem, beg explanation!