c# - Linq to SQL method defaults to ISingleResult -


i have stored procedure returns columns table (institutionentityip) maps dbml object of same name. return n number of records. however, codebehind defaults isingleresult. have return ienumerable.

i'm getting error message 'the query results cannot enumerated more once.'

my code looks this:

//contentrepository.cs private readonly igiglobaldatacontext db; // .... public ienumerable<institutionentityip> getinstitutionentityips(long fromip, long toip) {     return          ip in db.institutionentityips                 (             (fromip >= ip.fromipinteger && fromip <= ip.toipinteger) || //from ip address parameter same or encompassed             (toip >= ip.fromipinteger && toip <= ip.toipinteger) || //to ip address parameter same or encompassed             (fromip <= ip.fromipinteger && toip >= ip.fromipinteger) || //any ips in db between parameters              (fromip <= ip.toipinteger && toip >= ip.toipinteger) //any ips in db between parameters          ) &&         ip.isactive &&         ip.institutionentity.isactive &&         convert.todatetime((ip.institutionentity.expirationdate ?? (datetime?)datetime.now)) >= datetime.now &&         ip.institutionentity.institution.isactive &&         convert.todatetime((ip.institutionentity.institution.expirationdate ?? (datetime?)datetime.now)) >= datetime.now         select ip; } public ienumerable<institutionentityip> getinstitutionentityips(string fromip, string toip) {     // searchforconflictingips method name created when drop      // stored procedure (also called searchforconflictingips) on dbml layout     var ips = db.searchforconflictingips(fromip, toip); // returns isingleresult<institutionentityip>     // vvvvvvvvv     return ips.tolist(); // <-- needed specify .tolist() here <--     // ^^^^^^^^^ }  // call method class public static ienumerable<igiglobal_dal.institutionentityip> conflictingips(string start, string end) {     var cr = new contentrepository();     return cr.getinstitutionentityips(start, end); }  public rangevalidationresult validate(bool isupdate = false, int institutionentityipid = 0) {     var conflicts = conflictingips(start.tostring(), end.tostring());      if (conflicts.any()) // <---- 'the query results cannot enumerated more once.'     {         var conflictingentities = string.join(", ", conflicts.select(c => c.institutionentity.institutionentity1).distinct());     } } 

if need more information me please comment.

i needed specify .tolist() in public ienumerable getinstitutionentityips(string fromip, string toip) method.

found info needed here:
the result of query cannot enumerated more once


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -