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

LinqPad Result Error: InvalidOperationException

$
0
0
Hi,

I am unable to execute a linq request using linqpad. When I execute a linq request on a sql server 2008, I have an error that mention an Expr3 and TIMESTAMP but I don't know why...
I just bought the pro version for using it daily but I unfortunalely can't. I try to unistall the Linqpad 4 and install Linqpad 5 but the error is the same.
I also reinstall Windows but everything is the same...

Can anyone can solve this error?
Ps: sql request is ok

Thanks!

This is the error detail (in french - Sorry :) )
Message Membres 'System.Data.Linq.Binary Expr3' et 'System.Data.Linq.Binary TIMESTAMP' marqués comme versions de ligne.
Data Data
InnerException InnerException
TargetSite TargetSite
StackTrace à System.Data.Linq.Mapping.AttributedMetaType.InitSpecialMember(MetaDataMember mm)
à System.Data.Linq.Mapping.AttributedMetaType.InitDataMembers()
à System.Data.Linq.Mapping.AttributedMetaType..ctor(MetaModel model, MetaTable table, Type type, MetaType inheritanceRoot)
à System.Data.Linq.Mapping.AttributedRootType..ctor(AttributedMetaModel model, AttributedMetaTable table, Type type)
à System.Data.Linq.Mapping.AttributedMetaTable..ctor(AttributedMetaModel model, TableAttribute attr, Type rowType)
à System.Data.Linq.Mapping.AttributedMetaModel.GetTableNoLocks(Type rowType)
à System.Data.Linq.Mapping.AttributedMetaModel.InitStaticTables()
à System.Data.Linq.Mapping.AttributedMetaModel.GetTables()
à LINQPad.DataContextBase.Init()
à LINQPad.DataContextBase..ctor(IDbConnection connection, MappingSource mappingSource)
à LINQPad.User.TypedDataContext..ctor(IDbConnection connection)
à UserQuery..ctor(IDbConnection connection) dans C:\Users\Julien GONTIER\AppData\Local\Temp\LINQPad5\_eoridcru\query_tnthvp.cs:ligne 30
HelpLink null
Source System.Data.Linq
HResult -2146233079

Some queries no longer work on latest version of LinqPad4

$
0
0
After LinqPad4 updated itself today, all queries on tables with a binary timestamp as the unique ident throws the following error:

Members 'System.Data.Linq.Binary TIMESTAMP3W' and 'System.Data.Linq.Binary TIMESTAMP32' both marked as row version.

Linqpad 5 does not highlight var

$
0
0
LinqPad 4 highlights "var", but the current version of LinqPad 5 does not highlight "var". It looks odd.

Elasticsearch

$
0
0
Anyone using Linqpad with Elasticsearch? Hints on which nuget to use / or driver anywhere?

Link to XML in XML Column in Database

$
0
0
All, I have a database field with a string xml column.

I was trying to query the database for each string value and create a new XDocument / XElement and then query the xml for certain values. I keep getting the following error, when I use the string value from the database ... (This is from Linqpad)
Data at the root level is invalid. Line 1, position 1
However, if I take the same value from the database and create an xml file from it. It works fine.

This seems to be an encoding issue; but I haven't been able to solve it. I would rather not have to query each record, write it to a file and then process it. Any ideas on how to solve this problem?
my linq to sql query is ..
var query = from c in CmsContentXmls
where c.NodeId.Equals("1136")
select c.Xml;

my linq to xml query is ...
string sampleXML = query.ToString();
var doc = XElement.Load(new StringReader(sampleXML));

var results =
from e in doc.Descendants()
select e.Parent;
dpimental

NuGet beta packages not showing

$
0
0
I am running the latest beta since the current stable version does not show nuget packages with tags and the nuget search function does not work.

So I am running 4.56.6, but this version does not show beta packages for feeds you add. So I can see beta packages in the official nuget feed, but not my company feed. This feature is working in the latest stable version.

I am wondering if this is a known issue or if a fix needs to be made because its choose your poison on nuget features between the stable and beta version.

Set a default lambda input operator?

$
0
0
Is there a way to set linqpad to always use a specified input parameter? I find myself always using or changing the auto generated input parameter to 'x'. 'x' just seems to be faster when writing lambda expressions and it would be nice if we could force the usage of a specific letter instead of it being auto generated by the table name. i.e.

MyBigLongTableName.Where(mbltn => bla, bla, bla) to MyBigLongTableName.Where(x => bla, bla, bla)

Thanks!
Also, I am using v5.02.03 Premium Edition.

VB Expression allows multiple expressions (if they are statements)

$
0
0
Having checked, this is not new to LinqPad 5, it is repeatable in LinqPad 4.

Set the language to VB Expression
Paste this code:
CStr(1).Length
CStr(2).ToString
CStr(3).ToString
'CStr(40).Length

Note no syntax errors and running returns 1, the value of the first expression (which can still be any expression AFAICT).

If you uncomment the last line, it then complains "Property access must assign to the property or use its value." interactively in LinqPad 5 and at compile time in LinqPad 4.

Note you can also combine these "statements" on one line with colons with no warning or error.

However, this might actually be a feature for people who want to use the "selection runs what's selected" feature where they temporarily switch to VB Expression to run a part of a query and don't need dozens of red wiggly underlines in LinqPad 5.

Bug clicking Edit menu in Beta 5.06

$
0
0
Not sure if someone has already noticed this little problem.
If you highlight a block of code and then press the Edit menu, the highlight is removed and of course selecting Copy doesn't copy anything. This behavior doesn't happen with others menu.

Util.RawHtml and input box

$
0
0
With Util.RawHtml I can create an HTML input box in the result window. Is it possible to retrieve the contents of this input field in my c# code?

[BUG] Using an Entity Framework context from an existing assembly doesn't seem to work

$
0
0
Hello,

I found a bug with the functionality to use an existing managed assembly as a database connection, if it uses EntityFramework.

My windows version: 8.1 64 bit
LINQPad versions: 4.57.02 and 5.02.03, same bug on both

Steps to reproduce: Click add connection, select "User a typed data context from your own assembly", select Entity Framework (DbContext), click next, select my assembly, choose my database context type. Selecting the application config file or giving the connection a name doesn't seem to change anything in this case. Upon clicking test, or pressing OK and trying to use the connection, a default NullRefferenceException is displayed.
However, opening the SQL Server CE 4.0 database by targeting the database file directly works just fine.

My assembly uses EntityFramework 6.1.3 and EntityFramework.SqlServerCompact 6.1.3 as the database driver, both latest when making this report.

Here is my test program, didn't do much testing or mocking around with the code, just cut the essential portion from my production code to reproduce the bug:

using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.IO;

namespace BugTest
{
public class User
{
[Key]
public int ID { get; set; }
[Required]
public string Name { get; set; }
}

public class DBConf : DbConfiguration
{
public DBConf()
{
SetExecutionStrategy(@"System.Data.SqlServerCe.4.0", () => new DefaultExecutionStrategy());
}
}

[DbConfigurationType(typeof(DBConf))]
public class DB : DbContext
{
public DB(): base(GetConnectionString())
{
}

private static string GetConnectionString()
{
var ass = System.Reflection.Assembly.GetEntryAssembly();
var dir = Path.GetDirectoryName(ass.Location);
var name = ass.GetName().Name;
var connStr = "Data Source=" + dir + @"\" + name + ".sdf";
return connStr;
}

public DbSet<User> Users { get; set; }
}

internal class Program
{
private static void Main(string[] args)
{
using (var db = new DB())
{
db.Users.RemoveRange(db.Users);
db.Users.Add(new User { Name = "John" });
db.Users.Add(new User { Name = "Jane" });
db.Users.Add(new User { Name = "Peter" });
db.SaveChanges();
}
}
}
}


And here is everything from log.txt under %localappdata%\linqpad\logs, sadly I think unrelated.
4.51.03 2015-09-08T19:49:04.7732161+03:00 Downloading update from: http://www.linqpad.net/GetFile.aspx?updates4+457

4.51.03 2015-09-08T19:53:28.0770398+03:00 File: C:\Users\Gediminas\AppData\Local\Temp\LINQPad\_trftszxk\query_amldpi.dll could not be loaded: Could not load file or assembly 'file:///C:\Users\Gediminas\AppData\Local\Temp\LINQPad\_trftszxk\query_amldpi.dll' or one of its dependencies. The system cannot find the file specified.

4.57.02 2015-09-10T22:10:34.0718672+03:00 SymbolManager -
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at System.Diagnostics.SymbolStore.SymReader.GetMethod(SymbolToken method)
at LINQPad.Reflection.Internal.LocalVariableNameReader..ctor(MethodBase m)
at LINQPad.Reflection.Disassembler..ctor(MethodBase method, ILStyler styler)
First chance data:


Album showing bug reproduction: imgur.com/a/bJZsl

If I can provide any additional help feel free to ask, would be great to contribute to this awesome tool :)

Left panels (connections and My Queries) do not have correct colors in High Contrast (LINQPad 5)

$
0
0
Hi there

I'm using LINQPad 5 in high contrast mode. The left panels are not styled in high contrast colors. Can you please fix this?

Thanks,
Jacob

Cannot execute query after recent update

$
0
0
Hi there

I was using a C# query that retrieved some info from our Microsoft TFS database. This was working fine until a recent update was installed. I'm now receiving the following error:
Members System.Data.Linq.Binary Watermark and System.Data.Linq.Binary TimeStamp both marked as rowversion.

It seems that it has something to do with the component that is using for database connections. If I install a previous version of LINQPad 4 it works again (after first removing the files from programdate folder).

LINQPad 5 shows the same error when executing this query.

Can you please fix this or help me solve this issue?

Thanks,
Jacob

Trying to figure out how-2 per new "using static"

$
0
0
Simple example stymies me on how to get it into LinqPad 5 error free.
It does not like the usings. Complains they must precede all other elements defined in the namespace.
I get that - but it seems I used to get prompted to add the usings.

Maybe a more succinct question would be - how can I play with this new functionality?

using static System.Console;
using static System.Math;
using static System.DayOfWeek;

void Main()
{
WriteLine(Sqrt(3*3 + 4*4));
WriteLine(Friday - Monday);
}

Cannot select text using CTRL-A in some text boxes

$
0
0
As mentioned earlier here: http://forum.linqpad.net/discussion/comment/1926/#Comment_1926
I also noticed that the "Additional connection string parameters" textbox doesn't allow the text to be selected using CTRL-A hotkey.
This is also the case in the 'Additional Namespace Imports' (F4) textbox. CTRL-A simply doesn't work.

LINQPad v5.02.05 / Windows 10

Util.Run() cannot run consecutive scripts with identical data connection

$
0
0
I have created a few daily jobs as separate .linq files which I call from a main .linq script which iterates all "Daily - *.linq" files in the same directory, runs them and e-mails me the result:

(this is a small part with the relevant faulting line)
  foreach (var file in Directory.EnumerateFiles(path, "Daily - *.linq"))
{
sb.AppendFormat("<h2>{0}</h2>", Path.GetFileNameWithoutExtension(file));
sb.Append(Util.Run(file, QueryResultFormat.HtmlFragment).AsString());
}
I noticed strange behavior in some LINQ files which I could not explain. The error message I get is:
Daily - [Script name]

System.Exception: error CS0006: Metadata file 'C:\Users\Administrator\AppData\Local\Temp\LINQPad\_hgtdtpol\TypedDataContext_tukxem.dll' could not be found

at LINQPad.TaskExtensions.GetResult[T](Task`1 t)
at LINQPad.ChildAppHost.GetResult()
at LINQPad.ObjectModel.QueryExecuter.AsString()
at UserQuery.Main() in d:\LINQPad\RunDaily.linq:line 24
Today I found out this is not specific to Task Scheduler, user account or lprun.exe as it seems reproducible in LINQPad itself, so I'll post it here.

Steps to reproduce the problem:
1. Create a LINQPad file with a data connection (e.g. LINQ-to-SQL), the command or expression is not relevant to the problem.

MyScript.linq:
<Query Kind="Expression">
<Connection>
<ID>60154894-9165-4f77-b527-0bc717db8966</ID>
<Persist>true</Persist>
<Server>(local)</Server>
<NoPluralization>true</NoPluralization>
<NoCapitalization>true</NoCapitalization>
<Database>master</Database>
<ShowServer>true</ShowServer>
</Connection>
</Query>

"Test"
2. Create another LINQPad script which calls this script. In production, I'm calling different scripts with the same connection. To reproduce the problem, multiple runs to the same script is enought to reproduce the problem.
var path = Path.GetDirectoryName(Util.CurrentQueryPath);
var script = Path.Combine(path, "MyScript.linq");
for (var i = 0; i < 10; i++)
{
Util.Run(script, QueryResultFormat.HtmlFragment).AsString().Dump();
}
3. Run the main script, this is the result:

<div>Test<br /></div>
<div>Test<br /></div>
<div>Test<br /></div>

6FileNotFoundException4
Could not load file or assembly file:///C:\Users\Administrator\AppData\Local\Temp\LINQPad5\_rcvluirq\TypedDataContext_kqzkmz.dll or one of its dependencies.
I have found a workaround for this issue:
- Change the connection ID in the scripts that share the same connection.

Version(s) affected:
- v4.57.02
- v5.02.05

Cast fails on data from the Appdomain if anything changes in the .linq code

$
0
0
I have written code to process log files in LINQPad. I was planning on using the AppDomain to store the data read from the files and then filter the data on the next execution of the query. Below is a snippet of saving to and reading from the AppDomain.

AppDomain.CurrentDomain.SetData("aaLogData", LogRec.ToList());
List<LogFileRecord> data = ((List<LogFileRecord>)AppDomain.CurrentDomain.GetData("aaLogData"));


This works as long as I do not edit the query after the first execution. When I say edit, it could be something as simple as adding a comment to the code or something complex like modifying the code to filter the data read from the AppDomain.

I get the following exception:

[A]System.Collections.Generic.List`1[UserQuery+LogFileRecord] cannot be cast to [B]System.Collections.Generic.List`1[UserQuery+LogFileRecord]. Type A originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Type B originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
I have a simplified version of the code that reproduces the same error if needed.

I think this is a bug.

LINQPad v5.02.03 on Win 7 Pro 64-bit

Rename method does not affect symbol used inside nameof()

$
0
0
Hi, first of all, thank You for creating LinqPad. I love it!

During preparing examples for my what's new in c# 6.0 presentation i discovered a behavior that might be considered a bug.

In the following example if I try to apply rename (F2) to the method name, it does change the name in method header, but does not change the symbol used with nameof operator:
void Main()
{
nameof(SomeMethod).Dump();
}

public static void SomeMethod()
{
return;
}

kill a process on hitting stop button

$
0
0
I have this code:
Process p = Process.GetProcessByName("notepad").FirstofDefault();
if( p == null ) p = Process.Start("notepad.exe");
I wish to kill this p on hitting the stop button, how do I do that? thanks!

LinqKit PredicateBuilder Examples

$
0
0
I am trying to get the examples working found at http://www.albahari.com/nutshell/predicatebuilder.aspx

I have the following code:

public partial class PriceList
{
public string Name { get; set; }
public string Desc {get;set;}
public DateTime? ValidFrom {get;set;}
public DateTime? ValidTo{get;set;}

public static Expression> IsCurrent()
{
return p => (p.ValidFrom == null || p.ValidFrom <= DateTime.Now) && (p.ValidTo == null || p.ValidTo >= DateTime.Now);
}
}


void Main()
{
List plList = new List()
{
new PriceList(){ Name="Billy", Desc="Skilled", ValidFrom = DateTime.Now.AddDays(-10.0) , ValidTo= DateTime.Now.AddDays(1.0) },
new PriceList(){ Name="Jamie", Desc="Quick Study",ValidFrom =DateTime.Now.AddDays(-10.0) , ValidTo= DateTime.Now.AddDays(1.0) },
new PriceList(){Name= "Larry", Desc= "Rookie",ValidFrom = DateTime.Now.AddDays(-10.0) , ValidTo= DateTime.Now.AddDays(1.0) }
};

// Method 1
var myResultList = plList.Where ( p => (p.ValidFrom == null || p.ValidFrom <= DateTime.Now)
&& (p.ValidTo == null || p.ValidTo >= DateTime.Now)).Dump();

// Method 2

plList.Where(PriceList.IsCurrent()).Dump(); // This does not work currently


}
My question is between method 1 and method 2, the guts of the code are identical but when I call the Method 2 PriceList.IsCurrent I get the following error.

Any Suggestions would be greatly appreciated.

'System.Collections.Generic.List' does not contain a definition for 'Where' and the best extension method overload 'System.Linq.Queryable.Where(System.Linq.IQueryable, System.Linq.Expressions.Expression>)' has some invalid arguments

Instance argument: cannot convert from 'System.Collections.Generic.List' to 'System.Linq.IQueryable'

Viewing all 2703 articles
Browse latest View live