Пример #1
0
        /// <summary>
        /// Insert new childlink.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collection"></param>
        /// <param name="parentId"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static async Task <T> InsertChildById <T>(this IMongoCollection <T> collection, string parentId, T val) where T : NeuralLinkModel
        {
            val._id = Guid.NewGuid().ToString();
            var res = await collection.AddChildLinkById(parentId, val._id);

            if (res)
            {
                val.Parents.Add(parentId);
            }
            await collection.InsertOneAsync(val);

            return(val);
        }
Пример #2
0
 /// <summary>
 /// Links two nodes
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="collection"></param>
 /// <param name="parentId"></param>
 /// <param name="childId"></param>
 /// <returns></returns>
 public static async Task <bool> LinkParentChild <T>(this IMongoCollection <T> collection, string parentId, string childId) where T : NeuralLinkModel
 {
     return(await collection.AddChildLinkById(parentId, childId) && await collection.AddParentLinkById(childId, parentId));
 }