嘿,伙计们在从matisse对象数据库检索记录时遇到了问题,现在我很头疼。。。基本上尝试了所有内容,甚至使用计数消息框显示linq查询正在检索1个对象,但我在它应该工作的时候得到了一个IConvertable错误,基本上我正在尝试编辑现有记录,但它告诉我它需要IConverable,但这在使用SQL时可以工作,它也适用于其他使用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();
}
Persisten类(如Reptiles_Amphibians)必须包含在程序集中。
MtDatabase _db = new MtDatabase("localhost", "AnimalDB", new MtPackageObjectFactory("AssemblyName.AnimalsNamespace,AssemblyName", "DataBaseNamespace"));
并且在linq查询之前
_db.SqlCurrentNamespace = "DataBaseNamespace";s