About Efcore support for MySQL multi-field stitching query

Source: Internet
Author: User

This article is to discuss the support problem of Efcore to MySQL.

The ORM used in this article is MySql.Data.EntityFrameworkCore 6.10. Version 6

There is a table in the system: Crm.contacts contains the first_name and last_name two fields

In general, when you need queries, you need to concatenate the two fields together for a fuzzy query

MySQL supported SQL statements for SELECT * from ' crm.contacts ' where concat (first_name, last_name) like concat ('% ', ' abc ', '% ')

If you are using DbContext in your program. Crmcontacts.where (s = = (S.firstname + s.lastname). Contains ("abc")),

The SQL statement parsed out by Nero profile SQL intercepts the ORM framework for SELECT * from ' crm.contacts ' where first_name+ last_name like concat ('% ', ' abc ', '% ' )

MySQL does not support the above SQL statements

If you are using DbContext in your program. Crmcontacts.where (s) = string. Contat (S.firstname + s.lastname). Contains ("abc")),

The SQL statement parsed by Nero profile SQL intercepted by the ORM framework is select * from ' crm.contacts '

ORM gets all the contents of the table in memory for querying

But in Sqlserve, select * FROM [crm.contacts] where first_name+ last_name like '%abc% ' can be parsed so there is no such problem

About Efcore support for MySQL multi-field stitching query

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.