I try to code a Storagesystem and i got one Problem and dont know how to solve it...
public static List<string> GetAllItemsFromDB(string Searchbar)
{
List<string> retList = new List<string>();
retList.Clear();
var filter = Builders<DB_Package_Item>.Filter.Eq(Item => Item.Item_Name, Searchbar);
var ItemsMatch = Item_DB.Find(filter).ToList();
foreach (var Item in ItemsMatch.ToList())
{
retList.Add(Item.Item_Name);
}
return retList;
}
This Works. But when i change the filter to:
var filter = Builders<DB_Package_Item>.Filter.ElemMatch(Item => Item.Item_Name, Searchbar);
It crasches as soon i type any char in the searchbar with Error code : "System.InvalidOperationException: "The serializer for field 'Item_Name' must implement IBsonArraySerializer and provide item serialization info." "
I just dont get it why...
This is the Data_Package for MongoDB
public class DB_Package_Item
{
public Guid Id { get; set; }
public int Item_ID { get; set; }
public int Box_ID { get; set; }
public string Item_Name { get; set; }
public int Quantity { get; set; }
public string Partnumber { get; set; }
public string Supplier { get; set; }
}
Thx for every help!