entity framework - How to convert byte[] to string in c# -


to prevent concurrency have included field version timestamps type. don't no how convert version value string. please me solve problem.

using (mmp2012entities context = new mmp2012entities()) {     var res = (from in context.lin_laundry_issues     join sub in context.lin_laundry_iss_sub on i.issue_number equals sub.issue_number     join in context.mmp_items on sub.item_id equals it.id     i.issue_number==id && i.hospital_id==hospid && sub.status_ind==1     select new laundry_issuerecieptlist     {         issue_date = i.issue_date,         collected_by = i.collected_by,         authorised_by = i.authorised_by,         laundry_id = i.laundry_id,         item_id = sub.item_id,         item_name = it.name,         qty_issued = sub.qty_issued,         rate = sub.rate,         issue_number=i.issue_number,         subissueid=sub.laundry_trans_sub_id,         status_ind=sub.status_ind,         version=sub.version     }).tolist();     return res; } 

you can use function:

private string bytearraytostring(byte[] ba) {     stringbuilder hex = new stringbuilder(ba.length * 2);     foreach (byte b in ba) {         hex.appendformat("{0:x2}", b);     }      return hex.tostring(); } 

and reverse

private byte[] stringtobytearray(string hexstring) {     int length = hexstring.length;     int upperbound = length / 2;     if (length % 2 == 0) {         upperbound -= 1;     } else {         hexstring = "0" + hexstring;     }     byte[] bytes = new byte[upperbound + 1];     (int = 0; <= upperbound; i++) {         bytes[i] = convert.tobyte(hexstring.substring(i * 2, 2), 16);     }      return bytes; } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -