sepehr shams

sepehr shams

  • NA
  • 1
  • 983

how to find MS-SQL records corresponding to a binary string

Mar 17 2015 4:48 AM

how to read records from MS-SQL -corresponding to a binary string- to generic collection , suppose that our string is "10100" , corresponding records would be the 0-th, and second rows in table ("Operation" for example). one amateur (and of course incomplete) answer could be :

   
   public ICollection<Operation> GetAllowedOperations(string accessString)  
{
   PanelModel dbContext=new PanelModel();
var operationArray = dbContext.Operations.ToArray();//load from db to array
char[] accessArray = accessString.ToCharArray();//convert string to array
for (int i = 0; i <=accessArray.Count(); i++)//remove corresponding to 0
          {
if(accessArray[i].Equals('0'))
                {
                    operationArray[i] = null;
}
}
//assign array to a generic collection for future computation
what is an appropriate solution ,

Answers (1)