public T Get <T>(T entity) where T : Entity { string expand = ComposeExpands(entity); SOAPLikeEntityAPI <T> api = new SOAPLikeEntityAPI <T>(CurrentConfiguration); if (entity.ID.HasValue) { T resultByID = api.GetById(entity.ID, expand: expand); resultByID.ReturnBehavior = entity.ReturnBehavior; return(resultByID); } string filter = ComposeFilter(entity); var list = api.GetList(filter: filter); if (list.Count > 1) { throw new Exception("More than one entity satisfies the condition."); } if (list.Count == 0) { throw new Exception("No entities satisfy the condition."); } T result = api.GetById(list[0].ID, expand: expand); result.ReturnBehavior = entity.ReturnBehavior; return(result); }
public T GetById <T>(Guid?id, string select = null, string filter = null, string expand = null, string custom = null) where T : Entity { SOAPLikeEntityAPI <T> api = new SOAPLikeEntityAPI <T>(CurrentConfiguration); return(api.GetById(id, select, filter, expand, custom)); }
public T Get <T>(T entity) where T : Entity { string expand = ComposeExpands(entity); SOAPLikeEntityAPI <T> api = new SOAPLikeEntityAPI <T>(CurrentConfiguration); if (entity.ID.HasValue) { return(api.GetById(entity.ID, expand: expand)); } string filter = ComposeFilter(entity); var result = api.GetList(filter: filter); if (result.Count > 1) { throw new Exception("More than one entity satisfies the condition."); } return(api.GetById(result.FirstOrDefault().ID, expand: expand)); }