design - C# IQueryable or AsQueryable -


i'm prototyping sort of repository , want know if it's enough have methods, operate on sequences only.

for example:

public void addentities<t>(iqueryable<t> sequence); 

now, method prototype seems fine , generic, sucks when wants like:

var t = new t(); // add single entity. repository.addentities(???); 

what solutions case?

should make interface larger , add methods addsingleentity<t>(t t) , removesingleentity<t>(t t) or should leave , use like:

repository.addentities(new list { new t() }.asqueryable()); 

both choices have drawbacks: first 1 makes interface uglier , less compact, second looks bit weird.

what , why?

i create additional methods handle single entities operations, because cleaner , lot of common interfaces (list)

edit: if want have 1 method group:

public void add<t>(ienumerable<t> entities) { ... }  public void add<t>(params t[] entities) { this.add(entities.asenumerable()); } 

you can call:

repo.add(entity); repo.add(entity1, entity2); repo.add(entitylist); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -