Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This is the error that I am getting right now:

The argument types 'Edm.String' and 'Edm.Decimal' are incompatible for this operation. Near equals expression, line 1, column 156.

I know that this error is a compatibility issue but after going through the table and seeing that the parameters match up and I think are declared properly I would need to know the line of code that this references. The only ones that I would question are the data that are declared as money in the table but I declare them as decimal. This is the code that bombs out

        public ActionResult Details(int PVID = 0, int PMID = 0, decimal AID = 0.00M, decimal TID =0.00M, string TyID = null, string NID = null, decimal AmID = 0.00M, decimal PID = 0.00M, string TNID = null, string INID = null, DateTime? DEID = null, decimal IBID = 0.00M, decimal PBID = 0.00M, DateTime? LMDID = null)
    {
        tblDenialReport tbldenialreport = db.tblDenialReport.Find(PVID, PMID, AID, TID, TyID, NID, AmID, PID, TNID, INID, DEID, IBID, PBID, LMDID);
        if (tbldenialreport == null)
        {
            return HttpNotFound();

        }
        return View(tbldenialreport);
    }

Thank you for the help

share|improve this question
Are all those key values for model? – Bhushan Firake 26 mins ago

2 Answers

You should pass either the primary key or composite key as a parameter to DbSet<TEntity>.Find Method .You are doing it wrong here:

tblDenialReport tbldenialreport = db.tblDenialReport.Find(PVID, PMID, AID, TID, TyID, NID, AmID, PID, TNID, INID, DEID, IBID, PBID, LMDID);
  • DbSet<TEntity>.Find Method uses the primary key value to attempt to find an entity tracked by the context.
  • If the entity is not in the context then a query will be executed and evaluated against the data in the data source, and null is returned if the entity is not found in the context or in the data source.
  • Note that the Find also returns entities that have been added to the context but have not yet been saved to the database.
share|improve this answer

Based upon the error message I would guess the error is due to the fact that db.tblDenialReport.Find(...) expects an integer but you're passing strings and decimals as well.

share|improve this answer
It expects params[] – Bhushan Firake 22 mins ago
Ah, ok...it was a guess. – Ohlin 18 mins ago
Ok, I understand that the method can handle all kind of variables. But shouldn't they still be of the same kind? If the ID of the table is integer wouldn't there be an error if you send decimals and strings to the Find method? I guess I have some more reading to do here. Thanks for the link... – Ohlin 11 mins ago
:You can also have composite key consisting of an int and string, at that time you can pass an int as well as string separated by comma. – Bhushan Firake 7 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.