Ejemplo n.º 1
0
        /// <summary>
        /// TableA : TableA_FK,TableA_NavigateProperty,TableB,TableB_Key,OneToOne,TableB_Field1...[split_tag]
        /// </summary>
        /// <param name="cfg"></param>
        public void Parse_TableRelation(string cfg)
        {
            this.TableRelations.Clear();

            if (string.IsNullOrWhiteSpace(cfg))
            {
                return;
            }

            StringReader r    = new StringReader(cfg);
            string       line = null;

            while ((line = r.ReadLine()) != null)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    line = line.Replace(" ", "").Replace(".map", ":").Replace("(", "").Replace(")", "").Replace(";", "");
                    var ss = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                    var mr = new TableRelation();
                    mr.MainTable = ss[0].Trim().ToLower();
                    var ss_1 = ss[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    mr.MainFK           = ss_1[0].Trim();
                    mr.NavigateProperty = ss_1[1].Trim();
                    mr.ForeignTable     = ss_1[2].Trim().ToLower();
                    mr.ForeignKey       = ss_1[3].Trim();

                    RelationType type;
                    if (!Enum.TryParse <RelationType>(ss_1[4].Trim(), out type))
                    {
                        throw new Exception("关联类型不对:" + ss_1[4].Trim());
                    }
                    mr.Relation = type;

                    for (var index = 5; index < ss_1.Length; index++)
                    {
                        var s = ss_1[index].Trim().ToLower();

                        if (s.StartsWith("\""))
                        {
                            mr.DisplaySplit = s;
                        }
                        else
                        {
                            mr.ForeignDisplayFields.Add(s);
                        }
                    }

                    TableRelations.Add(mr);
                }
                catch (Exception e)
                {
                    ConnectionManager.FireValidateError(this.ConnectionString, e.Message);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TableA : TableA_FK,TableA_NavigateProperty,TableB,TableB_Key,OneToOne,TableB_Field1...[split_tag]
        /// </summary>
        /// <param name="cfg"></param>
        public void Parse_TableRelation(string cfg)
        {
            this.TableRelations.Clear();

            if (string.IsNullOrWhiteSpace(cfg))
                return;

            StringReader r = new StringReader(cfg);
            string line = null;
            while ((line = r.ReadLine()) != null)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(line))
                        continue;

                    line = line.Replace(" ", "").Replace(".map", ":").Replace("(", "").Replace(")", "").Replace(";", "");
                    var ss = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                    var mr = new TableRelation();
                    mr.MainTable = ss[0].Trim().ToLower();
                    var ss_1 = ss[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    mr.MainFK = ss_1[0].Trim();
                    mr.NavigateProperty = ss_1[1].Trim();
                    mr.ForeignTable = ss_1[2].Trim().ToLower();
                    mr.ForeignKey = ss_1[3].Trim();

                    RelationType type;
                    if (!Enum.TryParse<RelationType>(ss_1[4].Trim(), out type))
                    {
                        throw new Exception("关联类型不对:" + ss_1[4].Trim());
                    }
                    mr.Relation = type;

                    for (var index = 5; index < ss_1.Length; index++)
                    {
                        var s = ss_1[index].Trim().ToLower();

                        if (s.StartsWith("\""))
                            mr.DisplaySplit = s;
                        else
                            mr.ForeignDisplayFields.Add(s);
                    }

                    TableRelations.Add(mr);
                }
                catch (Exception e)
                {
                    ConnectionManager.FireValidateError(this.ConnectionString, e.Message);
                }
            }
        }