/// <summary> /// Parses an index /// </summary> /// <param name="index"></param> /// <returns></returns> protected virtual String ParseIndex(Index index) { String parsed = String.Empty; // PRIMARY KEY (`Name`) if (index.Any(attribute => attribute is Primary)) { parsed = String.Format("PRIMARY KEY ({0})", String.Join(", ", this.ParseSortings(index))); } return parsed; }
/// <summary> /// Parses an index /// </summary> /// <param name="index"></param> /// <returns></returns> protected virtual String ParseIndex(Index index) { Primary primary = index.FirstOrDefault(attribute => attribute is Primary) as Primary; Unique unique = index.FirstOrDefault(attribute => attribute is Unique) as Unique; JArray details = new JArray(); JObject sortings = new JObject(); foreach (Sort sort in index.Where(sort => sort is Sort)) { this.ParseSort(sort, sortings); } details.Add(sortings); if (primary != null || unique != null) { details.Add( new JObject() { new JProperty("unique", true) } ); } return details.ToString(Formatting.None); }