public bool Save() { MdbContext mongodb = new MdbContext(); RecabDataContext sqldb =new RecabDataContext(); Entity.Category cat = sqldb.Categoris.Find(this.CategoryId); if (cat == null) return false; Dictionary<string, string> temp = new Dictionary<string, string>(); temp.Add("Id", this.Id.ToString()); temp.Add("CategoryId", CategoryId.ToString()); foreach (ProductFeatureValue item in ListProperty) { CategoryFeature catfea = cat.Feature.SingleOrDefault(c=>c.Id== item.CategoryFeatureId); if (catfea == null) return false; temp.Add(catfea.Name , item.value); } return false; }
static void Main(string[] args) { MdbContext db = new MdbContext(); Dictionary<string, string> p = new Dictionary<string, string>(); p.Add("prop9", "val1"); p.Add("prop10", "val1"); object obj = new { PROP = p }; db.Categoris.InsertOne(obj.ToBsonDocument()); //Form form = new Form(); //Category cat = new Category(); //cat.Name = "Car"; //cat.Searchable = true; //for (int i = 0; i < 10; i++) //{ // CategoryFeature cf = new CategoryFeature(); // Element el = new Element(); // el.Title = "POP1-" + i.ToString(); // el.Required = true; // cf.HtmlElement = el; // cf.Name = el.Title; // cf.Searchable = true; // cat.Feature.Add(cf); //} //db.Categoris.InsertOne(cat.ToBsonDocument()); //for (int i = 0; i < 26; i++) //{ // Product pd = new Product(); // foreach (CategoryFeature cfItem in cat.Feature) // { // ProductProperty pdpro = new ProductProperty(); // pdpro.CategoryFeatureId = cfItem.Id; // pdpro.value = 1390+i.ToString(); // pd.Propertis.Add(pdpro); // } // pd.InsertTime = DateTime.UtcNow; // db.Prodocts.InsertOne(pd.ToBsonDocument()); //} }