There is no mapping from the object type System.Data.Objects.ObjectParameter to the known managed provider native type

Source: Internet
Author: User
Tags dname

Try to use T-SQL directly when using EF

There is such an implementation objectcontext.executestorequery

There is a constructor objectcontext.executestorequery (string S,parm object[] p)

It's all on the web.

Se. Executestorequery<departments> ("Select did, Dname, Dmanager from departments where [email protected ]"new ObjectParameter ("ID""1")

I don't know if someone else is running or not running correctly anyway, I'm having an exception.

After modification

Se. Executestorequery<departments> ("Select did, Dname, Dmanager from departments where did={0} ","1")

Run through data correctly

Cause: The Parm section needs to be constructed as follows

context.ExecuteStoreQuery<Product>("select * from Products where pid = {0}", 1);

Or

context.ExecuteStoreQuery<Product>("select * from Products where pid = @p0", new SqlParameter { ParameterName = "p0", Value = 1 });

There is no mapping from the object type System.Data.Objects.ObjectParameter to the known managed provider native type

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.