1

Below is my json string in MongoDB i want to delete MasterColors Array on MasterColorGuid in Asp.net Core

{
    "_id" : ObjectId("595657a00c1ac702f6e4f5cb"),
    "IsActive" : true,
    "IPAddress" : null,
    "CreatedBy" : "46F5C2E8-83F4-4062-8CD7-1B567B303919",
    "CreatedDateUtc" : ISODate("2017-06-30T13:51:38.324Z"),
    "ModifiedBy" : "46F5C2E8-83F4-4062-8CD7-1B567B303919",
    "ModifiedDateUtc" : ISODate("2017-06-30T13:51:38.324Z"),
    "WebSiteGuid" : "12E36FB8-D1B5-4172-8144-1176C0AFA82D",
    "ProductGuid" : "8D647BE5-8ABC-4AD8-8342-1254C8096DC8",
    "ProductName" : "Built® Netbook & Laptop Sleeve 9-10\"",
    "ProductCode" : "BT-5603",
    "MasterColors" : [ 
        {
            "MasterColorGuid" : "49e35057-39a6-4772-93c9-fc10aa87eff8",
            "SkuGuid" : "C634041D-116E-447A-A806-9CA04E4DA5B4"
        }, 
        {
            "MasterColorGuid" : "8ae4d05e-96f4-486d-9a2f-b1535f711f9f",
            "SkuGuid" : "04A03C81-07BC-4609-9311-C051784B1502"
        }
    ]
    }
5
  • Can you share .NET code you've written so far to delete the array? Commented Jul 6, 2017 at 13:47
  • the question is wrong i want to make a query to extract data from mongodb in asp.net core the query in mongodb is :db.getCollection('Products').distinct("ProductSKUs.VariantName" , {"WebSiteGuid":"12E36FB8-D1B5-4172-8144-1176C0AFA82D"}) in short i want to get all distincint varaint name of all products how will i pass this query in asp.net core. @Ignas Commented Jul 6, 2017 at 14:01
  • You should fix your question. See if this helps.stackoverflow.com/questions/44850951/… Commented Jul 6, 2017 at 14:11
  • Can we update the solution using Builders and Filterdefination of MongoDB driver @Veeram Commented Jul 6, 2017 at 14:31
  • I just did, but please update your question or you can just delete it. Commented Jul 6, 2017 at 15:06

1 Answer 1

0

var collection = _Productcontext.GetCollection(Collection); var distinct = collection .Distinct(new StringFieldDefinition("ProductSKUs.VariantName"), filterSelect) .ToList(); return distinct;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.