I have been trying to load single items from with LLBLGen by fields in the table that are not primary keys.
I can only work out how to filer on primary keys on FetchEntity.
To filter on non primary keys I am having to getthe collection and use linq to get the first. It fells like a smell, I was wondering if there was a better way?
public BinLocationEntity GetDefaultBinLocation(string firstName, string lastName)
{
var persons = new EntityCollection<PersonEntity>();
var filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(PersonFields.FirstName == firstName);
filter.PredicateExpression.Add(PersonFields.LastName== lastName);
using (var adapter = this.DataAccessAdapter)
{
adapter.FetchEntityCollection(persons , filter);
}
return persons .First();
}
I know the demo code would be bad in real world, Its just there as an example.