Пример #1
0
        private void PrepareDbClasses(IBSharpRuntimeProvider provider, Dictionary <string, XElement> result)
        {
            var dbclasses = provider.FindClasses(prototype: _context.BSharpPrototype).ToArray();
            var maps      = provider.FindClasses(prototype: _context.BSharpMapPrototype).ToArray();

            foreach (var cls in dbclasses)
            {
                _context.Log.Trace("cls " + cls.Fullname + " detected");
                var name = cls.Name;
                var xml  = cls.GetClassElement();
                result[name] = xml;
            }


            foreach (var map in maps)
            {
                foreach (var r in map.Definition.Descendants("ref"))
                {
                    var fromtable = r.ChooseAttr("table", "code");
                    var fromfield = r.ChooseAttr("name", "code");
                    var totable   = r.Value;
                    if (string.IsNullOrWhiteSpace(totable))
                    {
                        var cls = dbclasses.FirstOrDefault(_ => _.Fullname.EndsWith("." + fromfield));
                        if (null != cls)
                        {
                            totable = cls.Definition.Elements().First().Attr("table");
                        }
                    }
                    _context.Mappings.Add(new TableMap(fromtable, fromfield, totable));
                }
                foreach (var r in map.Definition.Descendants("disable"))
                {
                    var fromtable = r.ChooseAttr("table", "code");
                    var fromfield = r.ChooseAttr("name", "code");
                    _context.Indexes.Add(new TableMap(fromtable, fromfield, fromfield));
                }
            }
        }
Пример #2
0
	    private void PrepareDbClasses(IBSharpRuntimeProvider provider, Dictionary<string, XElement> result)
        {
            var dbclasses = provider.FindClasses(prototype: _context.BSharpPrototype).ToArray();
            var maps = provider.FindClasses(prototype: _context.BSharpMapPrototype).ToArray();
	        foreach (var cls in dbclasses) {
	            _context.Log.Trace("cls " + cls.Fullname + " detected");
	            var name = cls.Name;
	            var xml = cls.GetClassElement();
	            result[name] = xml;
	        }
	        
	       
	        foreach (var map in maps) {
	            foreach (var r in map.Definition.Descendants("ref")) {
	                var fromtable = r.ChooseAttr("table", "code");
	                var fromfield = r.ChooseAttr("name", "code");
	                var totable = r.Value;
	                if (string.IsNullOrWhiteSpace(totable)) {
	                    var cls = dbclasses.FirstOrDefault(_ => _.Fullname.EndsWith("." + fromfield));
	                    if (null != cls) {
	                        totable = cls.Definition.Elements().First().Attr("table");
	                    }
	                }
	                _context.Mappings.Add(new TableMap(fromtable, fromfield, totable));
	            }
	            foreach (var r in map.Definition.Descendants("disable")) {
	                var fromtable = r.ChooseAttr("table", "code");
	                var fromfield = r.ChooseAttr("name", "code");
	                _context.Indexes.Add(new TableMap(fromtable, fromfield, fromfield));
	            }
	        }
	    }