Quantcast
Channel: LINQPad Forum
Viewing all 2658 articles
Browse latest View live

Latest beta still throws "There are no usable .NET assemblies in package 'NETStandard.Library'."

$
0
0
I just downloaded v5.23.00(AnyCPU)

After adding few Microsoft.Extensions received following notification on screen.

image

Then went to Nuget installer and received following error.

image

Can LINQPad work with RethinkDB?

$
0
0
Anyone know if LINQPad can work with RethinkDB? I know there is a C# driver for RethinkDB, but not sure if there is a LINQPad driver for it, or whether I'd actually need one. Can anyone point me in the right direction?

Offline Activation message

$
0
0
I followed the instructions for offline activation and successfully activated LINQPad. However at the end of the process I was presented with the following message
Invalid Activation Code
I pressed the OK button and then had to press the Cancel button to get back to LINQPad. LINQPad was successfully licensed at the end of this.

LinqToDb update SQL

$
0
0
I would like to update the database. According to documentation and samples, I have to simply call SubmitChanges();

There is no SubmitChanges() when I use the LinqToDb providers.

Using:

DataContext dataContext = this;
..
dataContext.SubmitChanges();
is also not possible. The type DataContext of LinqToDb isn't compatible with 'this'.

Any idea? Thanks for your help.

Helmut

Linqpad Driver for Dynamics CRM - Throwing System.Exception

$
0
0
Dynamics CRM Web API Linq Pad Driver Data context which is used to connect the Dynamics CRM in LinqPad. After selecting and Connecting with CRM, I am getting System.Exception because of that cannot able use this DataContext. Below are the steps I have followed:

image
image

Stored Procedure

$
0
0
I am running a stored procedure that returns a few rows. When I run the stored procedure

ANI_MissingInvc()

It does not return any rows.

If I run as SQL

exec ANI_MissingInvc

I get the rows.

What am I doing worng?

Secondary server of Always On Availability Group ... ApplicationIntent=ReadOnly not working

$
0
0
Using LinqPad 5.22, how does one connect to a passive (readonly) server in a SQL Server AOAG? Adding "ApplicationIntent=ReadOnly" as an additional connection string parameter does not seem to be doing the trick.

Support C# 7.1

$
0
0
Any chance for support new version of C# 7.1?

Connection list - disabling to connect server during LINQPad start

$
0
0
Is there any option to disable some connections from list to connect at LINQPad's start ?
I have a lot of connections in my list, to remote servers witch are normally inaccessible and there is error message displayed
image
, just as my connection to SQL LocalDb starts SQL LocalDB server as site effect.

Thanks...

How to Update in Linq

$
0
0
I'm using a Data Context to connect to SQL Server and trying to troubleshoot an update. I have this much in Linqpad

var results = (from bl in a_Bellows_Lots
where bl.Job == "A2559038A"
where bl.BellowsLot == "17213A"
select bl).SingleOrDefault();

results.Quantity = 8;

???.SubmitChanges();

But I don't know what to call the update from.

My connection is called DataClasses1DataContext(kcserver2.support.PRODUCTION)

I tried DataClasses1DataContext, but it didn't have SubmitChanges sub command.

How do I make a SQL Server table update in Linqpad?

Thanks

Update Not Working

$
0
0
Can anyone see why this update does not update the value in the table?

var results = (from bl in a_Bellows_Lots
where bl.Job == "A2559038A"
where bl.BellowsLot == "17213A"
select bl).SingleOrDefault();

results.Quantity = 1;
this.SubmitChanges();


Compile LINQPad query (under C# Program-mode) into a standalone dll

$
0
0
Just curious that is there any way to find or compile the query (C# statements / programs) into a standalone dll.

There are times where I would like to create a new class in LINQPad, and export it as a dll.
e.g.

public class MyClass
{
private string _Name;
public string Name { get { return this._Name; } set { this._Name = value; } }
}

I wish to be able to export it as a dll on the fly.

Reference for learning basic LINQ for SQL? C# Expressions or C# Statements

$
0
0
Is there a simple reference/cheat sheet?

I'm familiar with C++ and some SQL.
I don't know why I should use Expressions, or Statements, or Entities and am mixing up the syntax so its confusing.
I just want to learn what I think should be simple things like:

SQL:
from p in ProviderInfo join r in TM99R.RM00101s on p.PHONE equals r.PHONE1 and r.INACTIVE = 0


LINQ does not have an AND so I tried
new{ p.PHONE ,r.INACTIVE } equals new{ r.PHONE1 ,1 }

but it complains: "CS0746 Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access."

SQL tab shows incomplete query for big insert (3000+ entries)

$
0
0
I'm currently making some simple inserts in my database, but I also need to save the SQL statements to use them later.

However, even though after the insert all values are in the table as expected, if I go check the generated SQL in the SQL tab, it only shows me inserts for the first 3280 values (this number is not the same, another query I ran only outputs 2900 values).

Is there any setting I can change so that it shows me the whole thing? Or is it a bug, or maybe intended behavior?

I'm currently using version 5.22.02, with a full license.

Is there a more optimal/elegant way to implement sub queries?

$
0
0
This works the way I want, but seems a lot of duplication and probably takes way longer than it needs to:

/*QA */ var providerIds = new[] { "315276" ,"145479" ,"455731" }; /**/ // match providers with customers by phone number /////////////////////////////////////// var matches = ( from p in ProviderInfo from r in TM99R.RM00101s.Where( r => ( p.PHONE.Substring( 0 ,10 ) == r.PHONE1.Substring( 0 ,10 ) || p.PHONE.Substring( 0 ,10 ) == r.PHONE2.Substring( 0 ,10 ) || p.PHONE.Substring( 0 ,10 ) == r.PHONE3.Substring( 0 ,10 ) ) ) /* QA */ where providerIds.Contains( p.Provnum ) orderby p.Provnum /**/ select new { actualPhone = p.PHONE.Substring( 0 ,10 ) ,p.Provnum ,r.CUSTNMBR } ); // group results /////////////////////////////////////// var providers = ( from p in matches /* QA */ where providerIds.Contains( p.Provnum ) orderby p.Provnum /**/ group p by new{ p.Provnum, p.actualPhone } into g select new{ Provnum = g.Key.Provnum ,Phone = g.Key.actualPhone ,CustomerCount = g.Count() // compile multiple customer numbers in to one string ,CustomerList = ( from cl in matches where cl.actualPhone == g.Key.actualPhone orderby cl.CUSTNMBR.Length select new { cl.CUSTNMBR } ).ToList() // select shortest CUSTNMBR string ,PrimaryCustomerNumber = ( from cl in matches where cl.actualPhone == g.Key.actualPhone orderby cl.CUSTNMBR.Length select new { cl.CUSTNMBR } ).ToList().First() } );

namespace cs1513 } expected

$
0
0
Been studying c# as a hobbyist for a while now. Just picked up LINQPad and decided to go back to the beginning and maybe try different things. That seems to be the beauty of LINQPad for me. Easy and quick playground. The side effect is that when something doesn't work as I expected I'm having a hard time knowing if it is my understanding of c# (high probability) or something about LINQpad I don't understand. At any rate, here's my question.

When working through some examples I decided to add "missing" class and namespace to the code. When I encompass the code with namespace TestPrograms {} I get the error cs1513 } expected. All my braces are matched. Hovering over the last brace shows (namespace) and there's the red squiggly right after that brace. This works fine in VS2017.

Here's the code I have:

// Here, we've refactored the logic in our original main method into a method called FeetToInches.
// (We have to go back to 'Program' mode for this.)
namespace TestPrograms
{
class Test
{
static void Main()
{
// This works when not static and placed within Main(); Why can't it be called outside of Main()? I have a feeling
// I'm missing something basic.
// int FeetToInches(int feet)
// {
// int inches = feet * 12;
// return inches;
// }

Console.WriteLine(FeetToInches(30)); // 360
Console.WriteLine(FeetToInches(100)); // 1200
Console.WriteLine(FeetToInches(0));
}

// what is the purpose of setting FeetToInches() to static?
//static int FeetToInches (int feet)
//{
// int inches = feet * 12;
// return inches;
//}

static int FeetToInches(int feet)
{
int inches = feet * 12;
return inches;
}

// I fell into a pattern of just declaring everything static because "that's the only way it worked"
}
}

how to insert results to sql table? (Specifically where to reference destination table)

[bug] Highly Type object to Util.Compile error

$
0
0
I'm having an issue passing in a highly type object to another script with the following code. I have extracted out my real logic into a test script that replicates the error.

In my parent script I have the following code

void Main()
{
var test = new TestObject { t1 = "asdf", t2 = 3 } ;

var compiledQuery = Util.Compile(@.\SubTestQuery.linq, false);
var retVal = compiledQuery.Run(QueryResultFormat.Html, test);
retVal.AsString();
}


[Serializable]
public class TestObject
{
public string t1 { get; set; }
public int t2
{
get; set;

}
}



in the SubTestQuery script I have the following code


async Task Main(TestObject input)
{
"In sub query".Dump();
await doSomething();
}

async Task doSomething()
{
return 1;

}



// Define other methods and classes here

[Serializable]
public class TestObject
{
public string t1 { get; set; }
public int t2
{
get; set;

}
}


but I get the following error

System.Runtime.Serialization.SerializationException
Unable to find assembly 'query_fewoae, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.


but if I place the TestObject class into my extensions I am able to run the parent script just fine. Is it possible to not have this class extension? I wish to pass around my scripts and it would be easier to define it in my scripts

Database Table field

$
0
0
Idea: Right click Table field in connections and have options to generate aggregates and distinct values of that field.

Group by field X.Count
FieldX.Distinct
Average, sum, min, max...

Util.Compile and Util.Run questions

$
0
0
Before I ask my questions I would like to state my end goal. I would like to do the following

1)Call a Subscript and output its Dump() in the main window.
2) Return a value from a Subscript.
3) Input a highly type object into a subscript.

I have manage to achieve 3 and sort of achieve 1 and 2

I can achieve 1 by using the Util.Run() method and also pass in string argument which is pretty nice. I also get the subscript .Dump() into my Results view window. Pretty cool and useful.

I can achieve 3 and 2 by using the following code and having the TestObject defined in MyExtensions script.

Parent Script
void Main() { Directory.SetCurrentDirectory (Path.GetDirectoryName (Util.CurrentQueryPath)); var details = new TestObject { /* whatever I want */ } var compiledQuery = Util.Compile(@".\SubTestQuery.linq", false); var retVal = compiledQuery.Run(QueryResultFormat.Html, details); retVal.ReturnValue.Dump();
}

SubScript with working return value
int Main(EnvironmentDetails input) { "Test Dump".Dump(); return 5; }
Using this method though I do not get my "Test Dump".Dump() in my results window in the parent script.



Once I change the subscript return value to async Task my ReturnValue becomes null. I still do not get the "Test Dump".Dump() in my parent script results window either which is expected from the result of the above test case.
async Task<int> Main(EnvironmentDetails input) { "Test Dump".Dump(); return 5; }


Is it possible to achieve all 3 ( well I guess 4) goals ? I have ran these scripts in the release version of linqpad 5 and the Download LINQPad 5.23.05 (Any CPU) beta.
Viewing all 2658 articles
Browse latest View live