Пример #1
0
        private void AddCompositePrimaryKey()
        {
            var keys = string.Join(", ",
                                   _table.Columns
                                   .Where(x => x.IsPrimaryKey)
                                   //primary keys must be scalar so if it's a foreign key use the Id mirror property
                                   //.Select(x => "x." + x.NetName + (x.IsForeignKey ? "Id" : string.Empty))
                                   .Select(x => "x." + ClassWriter.PropertyName(x))
                                   .ToArray());

            _cb.AppendLine("// Primary key (composite)");
            //double braces for a format
            _cb.AppendFormat(Builder + "HasKey(x => new {{ {0} }});", keys);
        }