Last active
March 11, 2024 10:07
-
-
Save simoncowie/57669d20c591df4dba57c35722741d10 to your computer and use it in GitHub Desktop.
Example: Simple way to save and fetch binary data to/from files using linqpad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set Language to "C# Program" in linqPad | |
void Main() | |
{ | |
var peopleWithPics = TblPersons | |
.Where(p => p.ProfilePicture != null) | |
.Select(p => new { p.PersonID, p.ProfilePicture }); | |
foreach(var p in peopleWithPics) | |
{ | |
System.IO.File.WriteAllBytes( | |
Path.Combine(@"D:\temp\", p.PersonID.ToString() + ".jpg"), | |
p.ProfilePicture.ToArray()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set Language to "C# Program" in linqPad | |
void Main() | |
{ | |
var file = System.IO.File.ReadAllBytes(@"D:\temp\4980.jpg"); | |
var person = TblPersons.First(p => p.PersonID == 5025); | |
person.ProfilePicture = file; | |
SubmitChanges(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment