0

Hey Guys having a problem retrieiving a record from a matisse object database, and its getting to me now... basically tried everything and even using a count message box shows that the linq query is retrieving 1 object however im getting a IConvertible error when it should be working, basically im trying to edit the exisitng record, however its telling me it needs to be IConvertible however this would work when using SQL and it also works for others using Matisse.

db.Open();

        Zoo.Data.Zoo editanimals = new Zoo.Data.Zoo(db);

        var animalidvar = animalid.Text;
        {
          Reptiles_Amphibians f = (from  Reptiles_Amphibians a in editanimals.Reptiles_Amphibianss where a.Animal_ID == animalidvar select a).FirstOrDefault<Reptiles_Amphibians>();


            f.Animal_ID = animalid.Text;
            f.Species = species.Text;
            f.Classification = classif.Text;
            f.Given_Name = givenname.Text;
            f.Photograph = photograph.Text;
            f.Date_Of_Birth = Convert.ToDateTime(dob.Text);
            f.Age = Convert.ToInt32(age.Text);
            f.Location_Code = location.Text;
            f.Born_Captivity_Wild = borncw.Text;
            f.Special_Notes = specnote.Text;
            f.Date_Joined = Convert.ToDateTime(datejoined.Text);
            f.Animal_Dimensions_Upon_Join = duj.Text;
            f.Average_Animal_Dimension = ad.Text;
            f.Average_Life_Span = averagelife.Text;
            f.Dietary_Requirements = diet.Text;
            f.Natural_Habitat_Description = nathab.Text;
            f.Average_Number_Of_Offspring = Convert.ToInt32(averageOffspringTxt.Text);
            f.Reproduction_Type = reproductionTxt.Text;
            f.Average_Clutch_Size = clutchSizeTxt.Text;
            f.Status = statusCombo.Text;
            db.Commit();

        }
        db.Close();
    }
Halfie44
  • 33
  • 1
  • 6
  • Have you tried running this through the debugger to determine which line the exception is occurring on? – M.Babcock Jan 30 '12 at 01:19
  • Its happening on the LINQ query :/ ive tried everything...going a tad mad aha – Halfie44 Jan 30 '12 at 13:21
  • What happens when you replace `.FirstOrDefault()` with just `.FirstOrDefault()`? Also, what's the point of the `{}`? They'll subscope `f`, but is it really necessary? – M.Babcock Jan 30 '12 at 13:27
  • getting the same problem when i have it as .FirstOrDefault(), the {} arent nessecary at all, the LINQ query is returning a value as its count is 1 – Halfie44 Jan 30 '12 at 13:59
  • Now I'm confused... I thought you said the exception was occurring in the LINQ query? – M.Babcock Jan 30 '12 at 14:02

1 Answers1

0

Persisten classes (like Reptiles_Amphibians) must be contained in the assembly.

MtDatabase _db = new MtDatabase("localhost", "AnimalDB", new MtPackageObjectFactory("AssemblyName.AnimalsNamespace,AssemblyName", "DataBaseNamespace"));

And before linq query

_db.SqlCurrentNamespace = "DataBaseNamespace";s
alxm
  • 51
  • 3