private void CreateCollection(IArangoDatabase db, string collectionName, CollectionType type = CollectionType.Document) { try { db.CreateCollection(collectionName, type: type); } catch (Exception) { // ignore, it already exists } }
/// <summary> /// detect if a type is vertex or edge and create the collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="arangoDatabase"></param> /// <returns></returns> public static bool CreateCollectionIfNotExist <T>(this IArangoDatabase arangoDatabase) where T : GraphBase { try { arangoDatabase.CreateCollection(typeof(T).Name, type: typeof(VertexBase).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) ? CollectionType.Document : CollectionType.Edge); return(true); } catch (Exception ex) { if (ex.Message.Contains("duplicate name")) { return(false); } else { throw ex; } } }
public void createCollection(string name) { var createResult = db.CreateCollection(name); }