Hi,
I am trying to return one entity out of an object's relational collection, but was getting an error if the collection was empty, so I added a check for an empty collection. If the collection is empty, I would like to return the NullEntity, but am having problems with the syntax to accomplish this.
The object model is thus: I have a Person entity, with a relation to "Involvements" (which indicate what roles a person has played in the organization).
This is my property code (Located in the Person Class):
/// <summary> /// The latest Involvement (aka Staff, Board, Volunteer) /// </summary> public Involvement LatestInvolvement { //TODO: Finish Person.LatestInvolvement & Test (Need test data in DB) get { ReadOnlyEntityList<Involvement> myList; Involvement rInvolvement;
myList = this.Involvements; myList.ApplySort("AuctionYear", System.ComponentModel.ListSortDirection.Descending, true); // Get the line items
if (myList.Count > 0) { rInvolvement= myList[0]; } else { rInvolvement = NullEntity; }
return rInvolvement; } }
|
My problem occurs at the
bolded line: "{ rInvolvement = NullEntity; }"
The Build error I get is:
Cannot implicitly convert type 'IdeaBlade.Persistence.Entity' to 'HS.Admin.Model.Involvement'. An explicit conversion exists (are you missing a cast?) I'm not sure what cast would be appropriate.
Thanks for any insights into how I can accomplish this.
Heather
Edited by HFloyd - 05-Sep-2008 at 12:18pm