Ef+mysql use problem, beg explanation!

Source: Internet
Author: User
Tags mysql version

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.