Instead of using try/catch to check for existing values, which is considered bad practice (exceptions are costly), you better use headers.AllKeys.Contains("User-Agent") to check for an existing value.
But, a shorter path is redefining the header. A…
C# c => c.Name translates to VB.NET Function(c) c.Name Dim customers = { New With {.Name = "John", .TotalOrders = 100}, New With {.Name = "Mary", .TotalOrders = 130}, New With {.Name = "Sara", .TotalOrders = 140}, New With {.Name = "P…
This is because the password is encrypted and the user/machine encryption key is somehow changed after the imaging process.
https://www.linqpad.net/FAQ.aspx#security
If I save a connection that uses SQL Authentication, does LINQPad store the passwo…
I'm not really familiar with the object change tracking of LINQ-to-SQL, but you could bypass this by creating (and releasing) a data context for each record (using new TypedDataContext, var rec = Forms.FirstOrDefault(), update, dispose by end using …
Have you looked at my (EF 6) example?
You linked a LINQ-to-SQL example, but are using Entity Framework. They use different methods. My example uses EF 6 methods (Table.Add and SaveChanges). EF 5 would require AddObject and SaveChanges).
Ah, Table<> is for LINQ-to-SQL generated data context.
For EF the code is a bit different. Doesn't explain why you get the 'Type could not be found' error. If it's visible in the tree view, I'd assume the type is in the current namespace.
Or…
Could you post your data model here? Because I just tried using the following example and 'it works on my machine' - Customer has a property of type IEnumerable and CashRegister a Customer property: CREATE SCHEMA cash -- Tables CREATE TABLE db…
You can utilize Util.WriteCsv for this. It accepts DataTables as well as IEnumerables. // Create a simple stored procedure (select and run): // ExecuteCommand("CREATE PROCEDURE sp_SelectTables AS SELECT * FROM sys.tables"); // After data conte…
I don't think these is a built in SQL Server function. Most examples show sqlcmd or powershell onelines.
A LINQPad example using Util.WriteCsv() would look like: var query = @"SELECT * FROM EMPL"; Connection.Open(); using (var table = new Dat…
So you're using the connection only as a placeholder, to be re-selected at runtime? Then you could store the LINQPad script without a connection and read the connection string via reflection. var connection = this.GetType().GetProperty("Connection")…
I'm not sure there is any LINQ-to-SQL method which can be used to translate into CONVERT(). But you could use direct ExecuteQuery() methods to embed this query in your c# statements script with typed objects. CREATE TABLE MS_CUSTOMER_MASTER_GRID ( …
Not sure if this answers your question, but it may give you something to start with.
Table layout: CREATE TABLE Teams ( TeamReference INT IDENTITY PRIMARY KEY NOT NULL, TeamName VARCHAR(128) NOT NULL ) CREATE TABLE Agents ( AgentRefe…
How are these tables related? Is TeamReference a foreign key to Teams? Does Team has a self-reference? Do you want to count all ApplicationReferences or unique values? Is DateDeleted relevant to the selection?
Any visualisation would help. What is …
My Extensions: void Main() { // Write code to test your extensions here. Press F5 to compile and run. } public static class MyExtensions { // Write custom extension methods here. They will be available to all queries. public static …
From http://www.linqpad.net/faq.aspx :
LINQPad encrypts the password securely using the Windows Data Protection API.
Not knowing the details of the Windows Data Protection API, I would simply decrypt the file on machine A to plain text and encrypt …
LINQPad uses LINQ to SQL, not Entity Framework.
For EF, it won't work, even with 'hackish' schema. void Main() { Database.SetInitializer(null); var connectionString = "Data Source=(local);Initial Catalog=master"; var databaseContext = n…
Assuming LINQPad premium, you can inspect the data context by pressing Alt+Shift+R (Query, Reflect Query in ILSpy).
It seems that nothing really special is going on, the additional types are declared in another class and the datacontext is passed b…