Forum: help
Monitor Forum | | Linq to entities : Include + OrderBy + Skip or Take : Wrong SQL generation [ reply ] By: Olivier MATROT on 2013-05-21 11:48 | [forum:1020694] |
|
Hello, I'm experiencing a small problem when using linq to entities. The usage of Include() with at least two levels of related objects in conjonction with Skip Or Take does produce incorrect SQL. This is always reproductible : var query = context.ExaminationDpi.Include(@"Examination.FunctionalUnits").OrderBy(ed => ed.Name).Skip(0).Take(25); does generate the following : SELECT "Project1"."exdid" AS "exdid","Project1"."exmid" AS "exmid","Project1"."exdlabel" AS "exdlabel","Project1"."exdcode" AS "exdcode","Project1"."exdfuncunit" AS "exdfuncunit","Project1"."exddefaultstatus" AS "exddefaultstatus","Project1"."exdlaterality" AS "exdlaterality","Project1"."xmin" AS "xmin","Project1"."exmid1" AS "exmid1","Project1"."extid" AS "extid","Project1"."anpcode" AS "anpcode","Project1"."mdccode" AS "mdccode","Project1"."exmlabel" AS "exmlabel","Project1"."exmdescription" AS "exmdescription","Project1"."exmduration" AS "exmduration","Project1"."exmftcount" AS "exmftcount","Project1"."exmindicator" AS "exmindicator","Project1"."exmcolour" AS "exmcolour","Project1"."datastatus" AS "datastatus","Project1"."xmin1" AS "xmin1","Project1"."C1" AS "C1","Project1"."funid" AS "funid","Project1"."svcid" AS "svcid","Project1"."funlabel" AS "funlabel","Project1"."funnumber" AS "funnumber","Project1"."funtypes" AS "funtypes","Project1"."funapplication" AS "funapplication","Project1"."corid" AS "corid","Project1"."datastatus1" AS "datastatus1","Project1"."tppid" AS "tppid","Project1"."xmin2" AS "xmin2" FROM ( SELECT "Extent1"."exdid" AS "exdid","Extent1"."exmid" AS "exmid","Extent1"."exdlabel" AS "exdlabel","Extent1"."exdcode" AS "exdcode","Extent1"."exdfuncunit" AS "exdfuncunit","Extent1"."exddefaultstatus" AS "exddefaultstatus","Extent1"."exdlaterality" AS "exdlaterality","Extent1"."xmin" AS "xmin","Extent2"."exmid" AS "exmid1","Extent2"."extid" AS "extid","Extent2"."anpcode" AS "anpcode","Extent2"."mdccode" AS "mdccode","Extent2"."exmlabel" AS "exmlabel","Extent2"."exmdescription" AS "exmdescription","Extent2"."exmduration" AS "exmduration","Extent2"."exmftcount" AS "exmftcount","Extent2"."exmindicator" AS "exmindicator","Extent2"."exmcolour" AS "exmcolour","Extent2"."datastatus" AS "datastatus","Extent2"."xmin" AS "xmin1","Extent4"."funid" AS "funid","Extent4"."svcid" AS "svcid","Extent4"."funlabel" AS "funlabel","Extent4"."funnumber" AS "funnumber","Extent4"."funtypes" AS "funtypes","Extent4"."funapplication" AS "funapplication","Extent4"."corid" AS "corid","Extent4"."datastatus" AS "datastatus1","Extent4"."tppid" AS "tppid","Extent4"."xmin" AS "xmin2", CASE WHEN ("Extent3"."exmid" IS NULL ) THEN (NULL) ELSE (1) END AS "C1" FROM "acadmin"."tconfigexaminationdpi" AS "Extent1" INNER JOIN "acadmin"."tconfigexaminations" AS "Extent2" ON "Extent1"."exmid"="Extent2"."exmid" ORDER BY "Extent1"."exdlabel" ASC OFFSET 0 LIMIT 25 LEFT OUTER JOIN "acadmin"."tconfigexmfuncunits" AS "Extent3" INNER JOIN "acadmin"."tfunctionalunits" AS "Extent4" ON "Extent3"."funid"="Extent4"."funid" ON "Extent1"."exmid"="Extent3"."exmid" ) AS "Project1" ORDER BY "Project1"."exdlabel" ASC ,"Project1"."exdid" ASC ,"Project1"."exmid1" ASC ,"Project1"."C1" ASC This one is very easily reproductible. I hope it will be fixed soon. |
|
| What does support="FF" mean? [ reply ] By: Katsutoshi Kasahara on 2013-05-02 00:51 | [forum:1020672] |
|
Hello, I use DbProviderFoctory with App.config for database connecting. I read user's manual, 3.4 Using Npgsql with ProviderFactory http://npgsql.projects.pgfoundry.org/docs/manual/UserManual.html Example of App.config as below. Anyone knows how support="FF" works ? and any values applicable? --- <?xml version="1.0" encoding="iso-8859-1" ?> <configuration> <system.data> <DbProviderFactories> <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" /> </DbProviderFactories> </system.data> </configuration> --- Thanks, Katsutoshi |
|
RE: What does support="FF" mean? [ reply ]
By: Francisco Figueiredo jr. on 2013-05-08 14:36[forum:1020676]
I couldn't find much information about that flag.
I could find this from msdn:
"Support is a bitmask of the types that the DbProviderFactory class can create using the DbProviderFactory.CreateXXX methods described above."
Reference: http://msdn.microsoft.com/en-us/library/ms379620(VS.80).aspx
I hope it helps.RE: What does support=&quot;FF&quot; mean? [ reply ]
By: Katsutoshi Kasahara on 2013-05-15 00:26[forum:1020693]
Hi Francisco,
Thank you for your helpful answer!
Sincerely.
| Establishing SSL Connection [ reply ] By: Jarrod Kinsley on 2009-05-19 18:14 | [forum:1004978] |
|
Could someone provide an example of establishing an SSL connection to PostgreSQL. I have a Windows application that talks to a PostgreSQL server on Linux. It works fine if I have SSL disabled, and I can make an SSL connection to the server using psql on the Vista box. When I set ssl=true and sslmode=require in the application, an IO Exception is thrown stating 'The authentication or decryption has failed.' At this point, I am assuming I am missing a step in establishing the SSL connection. However, I have been unable to find any example code for establishing an SSL connection such that one wuld expect to find in the user manual. I am not going to post code or trace information until I know the issue is not caused by me missing a step in the process. I am using VS2008 with Npgsql-2.0.5. For now I am just seeking an example of establishing the connection. If there is a underlying issue causing this problem, I will gladly provide additional information so that it can be fixed. |
|
| Entity Framework View missing column [ reply ] By: Kristoffer None on 2013-05-07 12:38 | [forum:1020674] |
|
Hey there, let me start by thanking you for providing such a great tool! Unfortunately I ran into a Problem: I am using Entity Framework to access my PostgreSql Database via an WCF-ODataService. The problem is the following when trying to access a view an exception is raised: {"ERROR: 42703: Column Extent1.C1 does not exist"}. Taking a closer look at the produced SQL it seems that it is invalid: --- Outer Query SELECT ... -- other defined columns ,CAST("Extent1"."Id" AS int4) AS "C1" ,CAST("Extent1"."Id_Grab" AS int4) AS "C2" ,CAST("Extent1"."Id_Parent" AS int4) AS "C3" ,CAST("Extent1"."Id_InstanceOf" AS int4) AS "C4" ,CAST("Extent1"."Id_File" AS int4) AS "C5" ,CAST("Extent1"."Id_GrabItemType" AS int4) AS "C6" FROM ( SELECT ... -- all columns of the view FROM "TestSchema"."MyView" "MyView" ) AS "Extent1" WHERE 4 = (CAST("Extent1"."Id_Grab" AS int4)) -- 4 is a value that the resultset should be filtered to ORDER BY "Extent1"."C1" ASC OFFSET 5 LIMIT 5 -- <--- !!!! This is the problem, -- the column C1 is not defined in the subquery, it gets defined on the outer query (by EF) --- Outer Query Could someone give some pointers how to solve this? Thank you very much for your time. Best Wishes, Kris |
|
RE: Entity Framework View missing column [ reply ]
By: Olivier MATROT on 2013-05-10 06:34[forum:1020684]
Hello Kris,
Could you provide the Linq query please ? I have experienced this kind of problem myself. Are you using anonymous objects ?
TIA.
| Can't load Npgsql driver with FluentNHibernate [ reply ] By: Brent Douglas on 2013-05-05 12:25 | [forum:1020673] |
|
Hi guys, I am pretty new to .net so please excuse any obvious oversights I am making. I am trying to run some unit tests for a class library I have and am getting the following exception: <pre> Test method xxxxx.core.tests.util.DatabaseTest.TestOpenSession threw exception: FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.NpgsqlDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider. at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow) at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at NHibernate.Driver.ReflectionBasedDriver..ctor(String providerInvariantName, String driverAssemblyName, String connectionTypeName, String commandTypeName) at NHibernate.Driver.NpgsqlDriver..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, ref Boolean canBeCached, ref RuntimeMethodHandleInternal ctor, ref Boolean bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, ref StackCrawlMark stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, ref StackCrawlMark stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) --- End of inner exception stack trace --- at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) at NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings) at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings) at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties) at NHibernate.Cfg.Configuration.BuildSettings() at NHibernate.Cfg.Configuration.BuildSessionFactory() at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() --- End of inner exception stack trace --- at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() at xxxxx.core.SessionFactory..ctor(String connectionString) in SessionFactory.cs: line 13 at xxxxx.core.tests.util.DatabaseTest.TestOpenSession() in DatabaseTest.cs: line 11 </pre> Which, correct me if I am wrong, sounds like Npgsql.dll can't be found. The project came from the default VS2012 C# class library template and the test project came from the C# unit test project. Both are targeting .NET 4.5 and have no other changes (except lower case packages) from the default properties. The test project has an app.config file with the following: <pre> <configuration> <connectionStrings> <add name="SomeDB" providerName="Npgsql" connectionString="Server=127.0.0.1;Port=5432;Database=xxxxxx;User Id=xxxxxx;Password=xxxxxx;"/> </connectionStrings> <system.data> <DbProviderFactories> <remove invariant="Npgsql"></remove> <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql Server" support="FF" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.12.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"/> </DbProviderFactories> </system.data> </configuration> </pre> I am using postgresql 9.2 on windows 7 professional. Both my class library and test projects have references to the Npgsql driver and Mono.Security with Copy Local set to true. I have checked and both these dll's are being copied into the project/bin/Debug directories. The Npgsql copy I have came from nuget and the references are to the copies localed in ${PROJECT_ROOT}\packages\Npgsql.2.0.12.1\lib\net40\Npgsql.dll (and same Mono.Security). VS reports Npgsql's version to be 2.0.12.0. I tried to load these to into the gac but when I did the copy of gacutil I have said it was built with .net 3.5 and could not load this version (I have v6.1 of the windows sdk installed). Can anyone please help me with what could be wrong because I feel like I have tried everything google can suggest to me. If you need any additional info to help me please ask and I will be only too happy to oblige. I have set a breakpoint in my test and the connection string is being loaded correctly so app.config file is being read as some stage. I don't really know how to debug library code in .Net though (any advice on that front would also be really appreciated btw). Brent Douglas |
|
| Linq .cont() generates invalid SQL [ reply ] By: Olivier MATROT on 2013-04-15 08:50 | [forum:1020637] |
|
I have a problem with the driver (2.0.12.0) that, in some cases, generates invalid SQL. First, a query is composed, filters are applied dynamically via query continuation. Second, rowcount is calculated (using .Count()) to obtain the total number of rows that will be returned. As you might have guessed already, the goal is to have paging support. Third, the query, without the row count, is issued and works well. I've been able to circumvent the problem to a specific restriction filter, and solved it by applying it earlier in the query continuation !? This is strange and this is why I suspect a provider bug. The INVALID SQL is following : SELECT "GroupBy1"."A1" AS "C1" FROM ( SELECT CAST (count(1) AS int4) AS "A1" FROM ( SELECT "Extent5"."rbkid" AS "rbkid" FROM "acaccount"."tmovement" AS "Extent1" INNER JOIN "acaccount"."tbillinginformation" AS "Extent2" ON "Extent1"."bilid"="Extent2"."bilid" INNER JOIN "acadmin"."tperformingphysicians" AS "Extent3" ON "Extent2"."physicianid"="Extent3"."ppyid" LEFT OUTER JOIN "acadmin"."tressources" AS "Extent4" ON "Extent3"."resid"="Extent4"."resid" LEFT OUTER JOIN "acaccount"."tpayment" AS "Extent5" ON "Extent1"."pytid"="Extent5"."pytid" LEFT OUTER JOIN "acaccount"."tpaymentmode" AS "Extent6" ON "Extent5"."pmid"="Extent6"."pmid" WHERE ("Extent1"."mvtstatus" IS NOT NULL ) AND (2!= (CAST ("Extent1"."mvtstatus" AS int4))) ) AS "Filter1" LEFT OUTER JOIN "acadmin"."tretailbanks" AS "Extent7" ON "Filter1"."rbkid"="Extent7"."rbkid" WHERE ((((("Filter1"."sitid"= (@p__linq__0)) AND ("Filter1"."svcid"= (@p__linq__1))) AND ("Filter1"."funid"= (@p__linq__2))) AND ("Filter1"."corid"= (@p__linq__3))) AND ("Filter1"."mvtentrydate">= (@p__linq__4))) AND ("Filter1"."mvtentrydate"<= (@p__linq__5)) ) AS "GroupBy1" THE VALID SQL is FOLLOWING : SELECT "GroupBy1"."A1" AS "C1" FROM ( SELECT CAST (count(1) AS int4) AS "A1" FROM "acaccount"."tmovement" AS "Extent1" INNER JOIN "acaccount"."tbillinginformation" AS "Extent2" ON "Extent1"."bilid"="Extent2"."bilid" INNER JOIN "acadmin"."tperformingphysicians" AS "Extent3" ON "Extent2"."physicianid"="Extent3"."ppyid" LEFT OUTER JOIN "acaccount"."tpayment" AS "Extent4" ON "Extent1"."pytid"="Extent4"."pytid" LEFT OUTER JOIN "acaccount"."tpaymentmode" AS "Extent5" ON "Extent4"."pmid"="Extent5"."pmid" LEFT OUTER JOIN "acadmin"."tretailbanks" AS "Extent6" ON "Extent4"."rbkid"="Extent6"."rbkid" WHERE ((((("Extent1"."sitid"= (@p__linq__0)) AND ("Extent1"."svcid"= (@p__linq__1))) AND ("Extent1"."funid"= (@p__linq__2))) AND ("Extent1"."corid"= (@p__linq__3))) AND ("Extent1"."mvtentrydate">= (@p__linq__4))) AND ("Extent1"."mvtentrydate"<= (@p__linq__5)) ) AS "GroupBy1" Does anyone ever hit the same problem ? TIA. |
|
RE: Linq .cont() generates invalid SQL [ reply ]
By: Josh Cooley on 2013-04-15 15:21[forum:1020641]
I'm trying to parse the SQL and understand what's broken, but I'm not sure I've spotted it. I see that the first one has a check on mvtstatus that the second one does not. What is wrong with the first one, and can you provide an example linq statement that generates the first and one that generates the second? RE: Linq .count() generates invalid SQL [ reply ]
By: Olivier MATROT on 2013-04-15 15:26[forum:1020642]
The first one have a check on mvtstatus, on the second didn't. This is not suppose to be like that !?
The second should have the check too. But it seems that it is lost. As I said I just moved the restriction up in the query composition.
Because it didn't break, I incorrectly supposed this was OK.
I'll try to post the queries, bu the model is slightly complex, I'll see what I can do.
Stay tuned.RE: Linq .count() generates invalid SQL [ reply ]
By: Josh Cooley on 2013-04-15 15:30[forum:1020643]
For now I just want to see sample linq and be able to identify what's broken in the SQL. We may have to get details on the model if that's necessary to reproducing the problem on our end. RE: Linq .count() generates invalid SQL [ reply ]
By: Olivier MATROT on 2013-04-15 15:41[forum:1020644]
All right, here we go :
System.Linq.IQueryable<BillingExtendedInformation> query = null;
query = from m in context.Movement
join aj2 in context.AccountingJournal on m.AccountingJournalId equals aj2.Id into aj1 from aj in aj1.DefaultIfEmpty()
join bi2 in context.BillingInformation on m.BillingInformationId equals bi2.BillId into bi1 from bi in bi1.DefaultIfEmpty()
//join d2 in context.Dunning on m.BillingInformationId equals d2.Id into d1 from d in d1.DefaultIfEmpty()
join b2 in context.Bill on bi.BillId equals b2.Id into b1 from b in b1.DefaultIfEmpty()
join p2 in context.Person on bi.PatientId equals p2.Id into p1 from p in p1.DefaultIfEmpty()
join c2 in context.Consultation on bi.ConsultationId equals c2.Id into c1 from c in c1.DefaultIfEmpty()
join pf2 in context.PerformingPhysician on bi.PerformingPhysicianId equals pf2.Id into pf1 from pf in pf1.DefaultIfEmpty()
join res2 in context.Resource on pf.ResourceId equals res2.Id into res1 from res in res1.DefaultIfEmpty()
join pt2 in context.Payment on m.PaymentId equals pt2.Id into pt1 from pt in pt1.DefaultIfEmpty()
join pm2 in context.PaymentMode on pt.PaymentModeId equals pm2.Id into pm1 from pm in pm1.DefaultIfEmpty()
join nr2 in context.NoemieReturnPayment on m.NoemieReturnPaymentId equals nr2.Id into nr1 from nr in nr1.DefaultIfEmpty()
join rb2 in context.RetailBank on pt.RetailBankId equals rb2.Id into rb1 from rb in rb1.DefaultIfEmpty()
// We need to work with an object who contains all the fields to be returned and all the fields where to apply restrictions
select new BillingExtendedInformation
{
MvtId = m.Id,
EntryDate = m.EntryDate,
//DueDate = m.DueDate.Value,
BookKeepingStatus = m.Status,
TppId = bi.ThirdPartyPayerId,
SiteId = m.SiteId,
ServiceId = m.ServiceId,
Distribution = bi.Distribution,
PerformingPhysicianId = bi.PerformingPhysicianId,
FunctionalUnitId = m.FunctionalUnitId,
CorporationId = m.CorporationId,
BillSecurityLevel = bi.SecurityLevel,
BillId = bi.BillId,
ConsultationId = c.Id,
PersonId = p.Id,
AmoId = bi.AmoId,
// A FAIRE : ThirdPartyName + jointure sur insurance id
AmcId = bi.AmcId,
PerFirstName = p.Firstname,
PerLastName = p.Lastname,
PerGender = p.Gender,
PerBirthDate = p.BirthDate.Value,
BillDate = bi.ConsultationDate,
ConsultationStudyId = c.StudyId,
SSNumber = p.Noss,
RegroupementCodes = bi.RegCode,
TotalConsultation = bi.TotalConsultation,
TotalAMO = bi.TotalAmo,
TotalAMC = bi.TotalAmc,
TotalPAT = bi.TotalPatient,
PerformingPhysicianFirstName = res.Firstname,
PerformingPhysicianLastName = res.Lastname,
BillingNumber = bi.BillingNumber,
BillingPatientStatus = bi.PatientStatus,
BillingAMOStatus = bi.AmoStatus,
BillingAMCStatus = bi.AmcStatus,
BillingOtherStatus = bi.TppStatus,
PaymentDate = m.EntryDate,
ExaminationDate = bi.ExaminationDate,
BankName = rb.Name,
PaymentMode = (FlagsPaymentModes)pt.PaymentModeId,
PaymentModeShortName = pm.ShortName,
PaymentID = pt.Id,
Payer = pt.Payer,
PaymentAmount = pt.Amount,
Change = pt.Change,
//DunningDate1 = d.FirstDate,
//DunningDate2 = d.SecondDate,
//DunningDate3 = d.ThirdDate,
//DunningLevel = d.Level
};
query = query.Where(q2 => q2.SiteId == filter.MainFilter.SiteId.Value);
query = query.Where(q2 => q2.ServiceId == filter.MainFilter.ServiceId.Value);
query = query.Where(q2 => q2.FunctionalUnitId == filter.MainFilter.FunctionalUnitId.Value);
query = query.Where(q2 => q2.CorporationId == filter.MainFilter.CorporationId.Value);
query = query.Where(q2 => q2.EntryDate >= filter.BillFilter.StartDate.Value && q2.EntryDate <= filter.BillFilter.EndDate.Value);
// This one will break the query count
query = query.Where(q2 => q2.BookKeepingStatus.HasValue && q2.BookKeepingStatus.Value != EntryStatus.Validated);
query.OrderBy(orderbyDateTimeExpression);
rowcount = query.Count(); // Will failRE: Linq .count() generates invalid SQL [ reply ]
By: Olivier MATROT on 2013-04-16 07:34[forum:1020670]
The rowcount computation generates the wrong SQL, thus fail.
If you replace this line with :
var result = query.ToList();
It works perfectly.
I\'ve done some more testing, and this is not the BookkeepingStatus that breaks the count computation... Sorry.
This is in fact a restriction that is missing in the query shown above.
Here we go again :
// This one will break the query count
query = query.Where(q2 => q2.BillId != null);
query = query.Where(q2 => q2.SiteId == filter.MainFilter.SiteId.Value);
query = query.Where(q2 => q2.SiteId == filter.MainFilter.SiteId.Value);
query = query.Where(q2 => q2.ServiceId == filter.MainFilter.ServiceId.Value);
query = query.Where(q2 => q2.FunctionalUnitId == filter.MainFilter.FunctionalUnitId.Value);
query = query.Where(q2 => q2.CorporationId == filter.MainFilter.CorporationId.Value);
query = query.Where(q2 => q2.EntryDate >= filter.BillFilter.StartDate.Value && q2.EntryDate <= filter.BillFilter.EndDate.Value);
query = query.Where(q2 => q2.BookKeepingStatus.HasValue && q2.BookKeepingStatus.Value != EntryStatus.Validated);
query.OrderBy(orderbyDateTimeExpression);
rowcount = query.Count(); // Will fail
RE: Linq .count() generates invalid SQL [ reply ]
By: Josh Cooley on 2013-04-15 19:03[forum:1020653]
If I understand correctly, it works until you add the BookKeepingStatus restriction. What makes the SQL generated wrong? I\'m missing that part of the problem. RE: Linq .count() generates invalid SQL [ reply ]
By: Olivier MATROT on 2013-04-16 06:21[forum:1020669]
The call to .Count() generates the wrong SQL.
If this line is commented out, and you execute the query, using .ToList() for instance, it works, the generated SQL is fine and the data is retreived.
This is why I\'m saying that the .count() may be the source of the problem.
RE: Linq .count() generates invalid SQL [ reply ]
By: Olivier MATROT on 2013-04-16 08:50[forum:1020671]
The wrong SQL is generated by the call to .Count().
I\'ve done some more testing, and it appears that it is not the bookkeepingstatus filter that is te cause of the problem, it is another restriction that I missed :
query = query.Where(q2 => q2.BillId != null);
This is the first restriction applied in the chain shown above. Also, I can say that it appears that the call to .Count() fails if a restriction is applied on nullable columns.
| Problem with nant tests when building from sources [ reply ] By: Maksym Boguk on 2013-03-14 23:22 | [forum:1020585] |
|
I run into problem with nant tests when tried build Npgsql2 from source. nant tests show next error sequence: build: [csc] Compiling 10 files to '/home/mboguk/postgres/Npgsql2/src/build/nunit2tests/NpgsqlTests.dll'. [csc] /home/mboguk/postgres/Npgsql2/testsuite/noninteractive/NUnit20/BaseClassTests.cs(31,7): error CS0246: The type or namespace name `NUnit' could not be found. Are you missing a using directive or an assembly reference? [csc] /home/mboguk/postgres/Npgsql2/testsuite/noninteractive/NUnit20/CommandTests.cs(32,7): error CS0246: The type or namespace name `NUnit' could not be found. Are you missing a using directive or an assembly reference? [csc] /home/mboguk/postgres/Npgsql2/testsuite/noninteractive/NUnit20/CommandTests.cs(49,6): error CS0246: The type or namespace name `TestFixture' could not be found. Are you missing a using directive or an assembly reference? [csc] /home/mboguk/postgres/Npgsql2/testsuite/noninteractive/NUnit20/CommandTests.cs(49,6): error CS0246: The type or namespace name `TestFixtureAttribute' could not be found. Are you missing a using directive or an assembly reference? and so on... It seems I missing some installed files or libraries. Any idea whow I can fix it? PS: nant version NAnt 0.91 (Build 0.91.3881.0; alpha2; 8/17/2010) |
|
RE: Problem with nant tests when building from sources [ reply ]
By: Francisco Figueiredo jr. on 2013-03-15 11:34[forum:1020586]
Are you using the build.sh file inside src folder?
Recently I notice that there is a little problem in the NpgsqlTests.build file regarding where it finds the nunit files.
This is how it finds those files:
<property name="nunit.files" dynamic="true"
value="${nant::get-base-directory() + '/lib/' +
framework::get-family(framework::get-target-framework()) + '/' +
int::to-string(version::get-major(framework::get-version(framework::get-target-framework()))) + '.' +
int::to-string(version::get-minor(framework::get-version(framework::get-target-framework()))) + '/nunit.*'}" />
The problem seems that this way of finding nunit files doesn't apply anymore to current versions of Mono.
I have to change this part of the file. For while, you can change this property to point to nunit files inside the common/2.0 folder.
Another possibility is to force the compilation to use the 2.0 framework by setting the -t:mono-2.0 parameter when calling src/build.sh or when calling nant directly.
I hope it helps.
RE: Problem with nant tests when building from sources [ reply ]
By: Maksym Boguk on 2013-04-09 05:29[forum:1020621]
Sorry for late responce.
Youre hint help fix an initial issue with tests.
Now I have another problem with nant tests:
[csc] /home/mboguk/postgres/Npgsql2.orig/testsuite/noninteractive/NUnit20/SystemTransactionsTest.cs(27,16): error CS0246: The type or namespace name `Description' could not be found. Are you missing a using directive or an assembly reference?
[csc] /home/mboguk/postgres/Npgsql2.orig/testsuite/noninteractive/NUnit20/SystemTransactionsTest.cs(27,16): error CS0246: The type or namespace name `DescriptionAttribute' could not be found. Are you missing a using directive or an assembly reference?
[csc] /home/mboguk/postgres/Npgsql2.orig/testsuite/noninteractive/NUnit20/SystemTransactionsTest.cs(44,16): error CS0246: The type or namespace name `Description' could not be found. Are you missing a using directive or an assembly reference?
[csc] /home/mboguk/postgres/Npgsql2.orig/testsuite/noninteractive/NUnit20/SystemTransactionsTest.cs(44,16): error CS0246: The type or namespace name `DescriptionAttribute' could not be found. Are you missing a using directive or an assembly reference?
RE: Problem with nant tests when building from sources [ reply ]
By: Francisco Figueiredo jr. on 2013-04-09 19:28[forum:1020623]
Nice catch!
In my dev machine, I have those commented out and replaced by a [Test] only.
I think this construction is from a newer version of NAnt. It may have come from a contribution which I didn't check correctly for backwards compatibility of NAnt. Sorry for that.
I'll have to change them in the cvs.
RE: Problem with nant tests when building from sources [ reply ]
By: Maksym Boguk on 2013-04-11 05:33[forum:1020628]
Hi Francisco,
Now I trying use build.bat for Windows 7 and I getting the following error:
[csc] Compiling 70 files to 'D:\Maxim\tmp\Npgsql2\src\build\ms\Npgsql.dll'.
[csc] d:\Maxim\tmp\Npgsql2\src\Npgsql\NpgsqlCommand.cs(301,41): error CS0501: 'Npgsql.NpgsqlCommand.ExpectedTypes.get' must declare a body because it is not marked abstract or extern
[csc] d:\Maxim\tmp\Npgsql2\src\Npgsql\NpgsqlCommand.cs(301,46): error CS0501: 'Npgsql.NpgsqlCommand.ExpectedTypes.set' must declare a body because it is not marked abstract or extern
BUILD FAILED
D:\Maxim\tmp\Npgsql2\src\Npgsql.build(281,10):
External Program Failed: C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe (return code was 1)
Any idea what's wrong there? Or what's wrong with my Win / .Net framework installation?
Kind Regards,
MaksymRE: Problem with nant tests when building from sources [ reply ]
By: Francisco Figueiredo jr. on 2013-04-11 19:28[forum:1020631]
Hmmmmmm, you are trying to compile it with ms.net 2.0. Did you check if you have sp1 of ms.net 2.0?
Did you try to compile with ms.net 3.5 or above?
RE: Problem with nant tests when building from sources [ reply ]
By: Maksym Boguk on 2013-04-12 00:17[forum:1020634]
I simple run build.bat in src folder.
build.bat automatically uses ms.net 2.0.
However, after I added -t:net-3.5 it build successfully.
Thank you for idea.
May be if the original code compatible with 3.5+ versions .Net only - it should use 3.5+ .Net compiler by default?
RE: Problem with nant tests when building from sources [ reply ]
By: Maksym Boguk on 2013-04-11 06:50[forum:1020629]
And one more problem:
Under Linux nant tests now producing the next error:
[copy] Copying 1 file to '/home/mboguk/postgres/Npgsql/src/build/nunit2tests'.
[copy] Copying 1 file to '/home/mboguk/postgres/Npgsql/src/build/nunit2tests'.
[copy] Copying 1 file to '/home/mboguk/postgres/Npgsql/src/build/nunit2tests'.
[copy] /home/mboguk/postgres/Npgsql/src/Npgsql.build(384,3):
[copy] Could not find file '/home/mboguk/postgres/Npgsql/src/build/ms/Npgsql.pdb' to copy.
[copy] Copying 1 file to '/home/mboguk/postgres/Npgsql/src/build/nunit2tests'.
Missing method .ctor in assembly /home/mboguk/postgres/Npgsql/src/build/nunit2tests/NpgsqlTests.dll, type NUnit.Framework.TestFixtureAttribute
Can't find custom attr constructor image: /home/mboguk/postgres/Npgsql/src/build/nunit2tests/NpgsqlTests.dll mtoken: 0x0a000195
BUILD FAILED - 1 non-fatal error(s), 0 warning(s)
Any idea what's wrong with it?RE: Problem with nant tests when building from sources [ reply ]
By: Francisco Figueiredo jr. on 2013-04-11 19:30[forum:1020632]
Which Mono version are you using?
RE: Problem with nant tests when building from sources [ reply ]
By: Maksym Boguk on 2013-04-12 00:20[forum:1020635]
I'm using:
mboguk@ubuntu:~$ mono -V
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
Installed traditional way (aptitide install ...) under Ubuntu Linux.
RE: Problem with nant tests when building from sources [ reply ]
By: Francisco Figueiredo jr. on 2013-05-08 01:44[forum:1020666]
Sorry for late reply....
I think the Mono 2.0 profile uses the compiler which supports constructions which ms.net 2.0 profile compiler doesn't. I'm saying that because when I compile Npgsql with Mono, it uses the 2.0 profile and doesn't raise any error.
I'll check that and return to you.
Now, about your problem when compiling with Mono, I still have no idea. I'll check that too.
Sorry for not being of much help on those issues right now... :(
| Adapter.Fill fails on ARM (BeagleBone) [ reply ] By: mickey feldman on 2013-04-10 21:32 | [forum:1020627] |
|
I have an application that I am mostly developing on a desktop PC but with the intention that it run on a BeagleBone (ARM architchture). Code that run on the x86 mono fails on the armel, throwing an exception when it hits Adapter.Fill. In both cases I'm running mono 2.10.8.1 on a Ubuntu 12.04 build, npgsql is 2.0.12.0. I did find another ARM related issue with mono that has to do with the formatting of DateTime (not sql datetime, not npgsql related), and I'm not surprised if arm support lags x86. Is this a known problem, and is there a fix or workaround? Here's my stacktrace: 2013/04/10 13:30:49 System.TypeInitializationException() An exception was thrown by the type initializer for System.Data.SqlTypes.SqlDecimal at System.Data.DataColumn..ctor (System.String columnName, System.Type dataType, System.String expr, MappingType type) [0x00000] in <filename unknown>:0 at System.Data.DataColumn..ctor (System.String columnName, System.Type dataType) [0x00000] in <filename unknown>:0 at System.Data.DataColumnCollection.Add (System.String columnName, System.Type type) [0x00000] in <filename unknown>:0 at Npgsql.NpgsqlDataReader.GetResultsetSchema () [0x00000] in <filename unknown>:0 at Npgsql.NpgsqlDataReader.GetSchemaTable () [0x00000] in <filename unknown>:0 at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, System.Data.Common.DataTableMappingCollection dtMapping) [0x00000] in <filename unknown>:0 at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType) [0x00000] in <filename unknown>:0 at System.Data.Common.DataAdapter.FillTable (System.Data.DataTable dataTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, System.Int32& counter) [0x00000] in <filename unknown>:0 at System.Data.Common.DataAdapter.FillInternal (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x00000] in <filename unknown>:0 at System.Data.Common.DataAdapter.Fill (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x00000] in <filename unknown>:0 at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) [0x00000] in <filename unknown>:0 at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet) [0x00000] in <filename unknown>:0 at Vigil.Public.Database.SQLDatabase.GetDataTable (System.String strSQL) [0x00000] in <filename unknown>:0 |
|
RE: Adapter.Fill fails on ARM (BeagleBone) [ reply ]
By: mickey feldman on 2013-04-11 13:23[forum:1020630]
I think this is probably bug #10857 in Mono, not in npgsql as such, and will pursue it there. RE: Adapter.Fill fails on ARM (BeagleBone) [ reply ]
By: Francisco Figueiredo jr. on 2013-04-11 20:22[forum:1020633]
Great! I'm glad you found a reference. I didn't have any clue about this problem too :)
| Connection pool : Timeout after some time [ reply ] By: Olivier MATROT on 2013-03-13 18:58 | [forum:1020581] |
|
Hello, I'm using Npgsql 2.0.12.0 in the context of Entity Framework in a WCF service hosted in IIS. With connection pooling enabled at the connection string, everything works fine for several hours and suddenly, it is impossible to get a connection from the pool : System.Data.EntityException: The underlying provider failed on Open. ---> System.Exception: Timeout while getting a connection from pool. at Npgsql.NpgsqlConnectorPool.RequestPooledConnector(NpgsqlConnection Connection) at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection Connection) at Npgsql.NpgsqlConnection.Open() at EFProviderWrapperToolkit.DbConnectionWrapper.Open() at EFProviderWrapperToolkit.DbConnectionWrapper.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectContext.ExecuteStoreCommand(String commandText, Object[] parameters) at Accel.Is.Data.EF.AccelIsExtendedContext.SetApplicationName(String clientAppName, String login) at Accel.Is.Data.Service.BillingService.GetBill(Int32 Id, EagerLoadingRules loadDependencies) What are the known reasons for a timeout getting a connection ? How could I help diagnose the problem ? Thanks in advance. |
|
RE: Connection pool : Timeout after some time [ reply ]
By: Francisco Figueiredo jr. on 2013-03-14 16:15[forum:1020583]
Hi, Olivier.
The most common cause for this type of error is some missing connection dispose or close.
I have a modified Npgsql codebase where I tested some tracing in order to help diagnose why the pool isn't returning a connection. Whenever you get a timeout from the pool, Npgsql writes to a log file the stack trace of the allocation of all the connections which are in the pool. This way, it is easy to see where the connection on the pool was obtained and check why it wasn't released.
I still have to integrate this change to the main codebase. In the current state it is more like a hack than anything else :)
If you would like to give it a try, please let me know. I can send you a binary which you can drop in place of your existing Npgsql.
I hope it helps.
RE: Connection pool : Timeout after some time [ reply ]
By: Olivier MATROT on 2013-03-15 12:48[forum:1020588]
Hi Francisco,
This is very interesting.
May be you could send me the code, and I'll integrate it in my 'private branch'.
I'm using a modified version of the provider, based on the code delivered in version 2.0.12.0.
Thanks in advance.RE: Connection pool : Timeout after some time [ reply ]
By: Francisco Figueiredo jr. on 2013-03-15 12:57[forum:1020589]
Thinking about that possibility, yesterday I created a gist containing the file I changed in order to get that.
Please, give it a try and let me know if you have any problems.
https://gist.github.com/franciscojunior/5162829RE: Connection pool : Timeout after some time [ reply ]
By: Olivier MATROT on 2013-03-17 15:43[forum:1020590]
Hi francisco,
I found the source of the bug which was in my code.
Basically, I was explicitely opening the connection through the EF context to avoid transaction promotion (http://msdn.microsoft.com/en-us/library/bb738530(v=vs.90).aspx)
But I was not explicitely closing the connection, which was the reason for the leak.RE: Connection pool : Timeout after some time [ reply ]
By: Francisco Figueiredo jr. on 2013-03-25 12:11[forum:1020605]
Hi, Olivier! Sorry for late reply.
I'm glad to hear you found the source of the problem.
Did the modified version of Npgsql help you to find the problem? I'm asking this feedback in order to verify if the change is really helpful. If so, I'll implement it in the official version so others can use it to find connection leaks.
Thanks in advance.RE: Connection pool : Timeout after some time [ reply ]
By: Olivier MATROT on 2013-03-25 12:18[forum:1020606]
Hi Francisco,
Unfortunately, the modified version was'nt helpful in this particular case.
I was able to find the leak by adding logging in the thread that deals with the connection pool to ensure that the minimum number of connection in the pool is met.
There is a little bug though, as the timer behind this thread is started even if connection pooling is disabled. It would be nice to disable it in this case.RE: Connection pool : Timeout after some time [ reply ]
By: Francisco Figueiredo jr. on 2013-03-25 12:33[forum:1020607]
I see.
But when you used the modified version, didn't the log show the stacktraces of the connections in the pool indicating that they were explicited allocated through the EF context like you said?
The idea of this modified version is exactly be able to tell you that so you don't need to add logging yourself.
About the time, would you mind to fill a bug report about that?
Thank you very much for your help and feedback.
RE: Connection pool : Timeout after some time [ reply ]
By: Olivier MATROT on 2013-04-05 06:50[forum:1020615]
Sorry for the late reply.
Yes the stack trace was interresting.
Be sure to not request (and include) the stack trace if logging is disabled, as it is a costly operation.
I'll file a bug for the pooling thread.
| WCF, Entity Framework, Connection pool, and distributed (PREPARED) transactions [ reply ] By: Olivier MATROT on 2013-03-17 19:21 | [forum:1020591] |
|
Hi, It seems that there is a problem with connection pooling and TransactionScope. In a WCF service, a connection that is enlisted in a transaction (BeginTransaction() has been called) should not be put back in the pool, because it will be used by another thread and you can't Prepare and Commit or Rollback the transaction. I also have done some tests without connection pooling and it also fails. PREPARE TRANSACTION does not return an error but the server log says that there is no current transaction (Begin has not been called) Because COMMIT PREPARED is called from a Npgsql owned thread, it throws an exception and kills the WCF Service. I will try to give you traces in order to understand the problem. Stay tuned. |
|
| 2.0.12 CommandBuilder/DataAdapter problem [ reply ] By: Nenad Konstantinovik on 2012-11-18 22:29 | [forum:1020368] |
|
I switched from 2.0.11 to 2.0.12 and started to receive errors "Update requires a valid UpdateCommand when passed DataRow collection with modified rows", and likewise for insert and delete operations. I checked the CommandBuilder, it's generating the commands, but when trying to execute the DataAdapter.Update command, I get the error. Is something changed in relation to this in the new version? Thank you |
|
RE: 2.0.12 CommandBuilder/DataAdapter problem [ reply ]
By: Francisco Figueiredo jr. on 2013-03-15 11:37[forum:1020587]
Hi, Nenad. Sorry for so late reply.
Are you still getting this problem? I remember I changed NpgsqlDataAdapter to fix a bug which may have caused this problem.
I'll check this error and will let you know if I find anything.
| Resource Manager Guid [ reply ] By: Olivier MATROT on 2013-03-13 16:48 | [forum:1020579] |
|
Hello, I'm using Npgsql in the context of Entity Framework in a WCF service Hosted in IIS. I have several services hosted in the same process (one per appdomain I think). I have an issue with the System.Transactions implementation. I have the following error : System.Data.EntityException: The underlying provider failed on Open. ---> System.Runtime.InteropServices.COMException: A resource manager with the same identifier is already registered with the specified transaction coordinator. (Exception from HRESULT: 0x8004D102) Server stack trace: at System.Transactions.Oletx.IDtcProxyShimFactory.CreateResourceManager(Guid resourceManagerIdentifier, IntPtr managedIdentifier, IResourceManagerShim& resourceManagerShim) at System.Transactions.Oletx.OletxResourceManager.get_ResourceManagerShim() at System.Transactions.Oletx.OletxResourceManager.EnlistDurable(OletxTransaction oletxTransaction, Boolean canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions) at System.Transactions.Oletx.OletxTransaction.EnlistDurable(Guid resourceManagerIdentifier, ISinglePhaseNotificationInternal singlePhaseNotification, Boolean canDoSinglePhase, EnlistmentOptions enlistmentOptions) at System.Transactions.TransactionStatePromotedBase.EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) at System.Transactions.Transaction.EnlistDurable(Guid resourceManagerIdentifier, ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions) at Npgsql.NpgsqlResourceManager.DurableResourceManager.Enlist(Transaction tx) at Npgsql.NpgsqlResourceManager.DurableResourceManager.Enlist(Byte[] token) at Npgsql.NpgsqlResourceManager.Enlist(INpgsqlTransactionCallbacks callbacks, Byte[] txToken) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Npgsql.INpgsqlResourceManager.Enlist(INpgsqlTransactionCallbacks transactionCallbacks, Byte[] txToken) at Npgsql.NpgsqlPromotableSinglePhaseNotification.Enlist(Transaction tx) at Npgsql.NpgsqlConnection.Open() at EFProviderWrapperToolkit.DbConnectionWrapper.Open() at EFProviderWrapperToolkit.DbConnectionWrapper.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) at Accel.Is.Data.Service.StudyService.UpdateEnhancedTrackableCollectionOfTechnicalpackage(EnhancedTrackableCollection`1 listTechnicalpackage) at SyncInvokeUpdateEnhancedTrackableCollectionOfTechnicalpackage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) From what I understand, this is because The resource manager is using a static guid. The documentation states that we should provide "A unique identifier for a resource manager, which should persist across resource manager failure or reboot." Well I understand that this Guid should be unique given an appdomain. The current design prevents the enlistment in transactions if there is more than one process/appdomain on the current machine using Npgsql. I will try to use a new generated Guid. |
|
RE: Resource Manager Guid [ reply ]
By: Francisco Figueiredo jr. on 2013-03-13 16:58[forum:1020580]
Hi!
Would you please, try the code from cvs?
There were some changes to the transaction scope which may be or may be not related to your case, but it would help us to integrate a possible patch you create.
Thanks in advance.RE: Resource Manager Guid [ reply ]
By: Olivier MATROT on 2013-03-13 19:05[forum:1020582]
Of course I will try it.
I'm unable to browse the CSV repository through this link right now :
http://pgfoundry.org/scm/browser.php?group_id=1000140
Is there an alternative link ?RE: Resource Manager Guid [ reply ]
By: Francisco Figueiredo jr. on 2013-03-14 16:18[forum:1020584]
Unfortunately, pgfoundry is having problems with source browsing.
You can get the code with cvs though.
Another alternative is to browse through github: http://git.npgsql.org. I try to keep the github repository in sync with pgfoundry cvs.
I hope it helps.
| VisualStudio NpgsqlException [ reply ] By: Lucas Phillip on 2013-01-04 15:15 | [forum:1020432] |
|
Hi there, We started testing with Npgsql to migrate our database from sqlserver. So far we got everything working just fine, except for one little thing. Our code works fine if executed outside from Visual Studio. But if it is executed from VS, we get a "ERROR: 3F000: schema \"dbo\" does not exist" exception the first time a connection is made. If we continue the execution, then we do not get the exception anymore and every query works. Can anyone enlight this problem for us? We could not find anything similar on the web. Thanks, Lucas |
|
RE: VisualStudio NpgsqlException [ reply ]
By: Jon Sutter on 2013-01-04 15:48[forum:1020433]
We have not seen this behavior. We are using VS2012, EF 5.0 Code First with class generated using the "Entity Framework | Reverse Engineer Code First".
We did see a similiar schema issue in that the EF mapping classes generated did not have a schema parameter defined in the "ToTable()" call and Entity Framework would assumbe "dbo" for the schema. Once we put a call in to dynamically determine the schema by looking at the connection string we could use any schema, dbo for sql server, public for PostgreSQL, or whatever we wanted.RE: VisualStudio NpgsqlException [ reply ]
By: Lucas Phillip on 2013-01-04 20:10[forum:1020434]
I'm using VS 2010, EF 4.1
I've set the schema using ToTable() within the overridden OnModelCreating. Like I said, the program works just fine if I run the app outside Visual Studio, and it only happens once within VS.
It is a very weird thing.
RE: VisualStudio NpgsqlException [ reply ]
By: Damian W on 2013-03-06 22:12[forum:1020571]
I think the exact query looks like this:
SELECT "Extent1"."Id" AS "Id","Extent1"."ModelHash" AS "ModelHash" FROM "dbo"."EdmMetadata" AS "Extent1" ORDER BY "Extent1"."Id" DESC LIMIT 1
Official Microsoft answer as I reported that as a bug on http://connect.microsoft.com:
<quote>
This is by design. Entity Framework catches the exception internally and deduces from this that the table doesn’t exist. Using this information it makes decisions about how to handle initialization.
If you know that you don’t need initializers, then disable them for your context by calling Database.SetInitializer<MyContext>(null) as part of your app startup. EF will then not attempt to check for the EdmMetadata table.
Thanks,
EF Team
</quote>
| Listen/Notify question [ reply ] By: Michael Dillon on 2012-09-20 18:13 | [forum:1020138] |
|
I'm using npgsql version 2.0.12.0 and .NET 4 I'm have a simple test application that uses npgsql to listen for channel notifications. I'm setting the SyncNotification flag to true. The source is here http://pastebin.com/k7kP7RSQ Using PgAdmin, I'll send all these notifications at once: notify my_channel, 'starting'; BEGIN; notify my_channel, 'ping 1'; notify my_channel, 'ping 2'; COMMIT; notify my_channel, 'test 1'; notify my_channel, 'test 2'; notify my_channel, 'done'; The application will only print the initial "starting" message. Once I send an additional message, the application will print all the previous messages. Using Wireshark, I've verified that our server sends each notification as I would expect, but npgsql seems to queue all the messages. If I send individual messages, things also work as expected (except for the messages done in a transaction). In short, it seems like the npgsql driver is holding all the messages until it's 'nudged' by a new incoming notification. How can I prevent this behavior? Thanks, Mike |
|
RE: Listen/Notify question [ reply ]
By: Alexander Golikov on 2012-09-21 08:25[forum:1020139]
it's not so simple as you think :(
It is old bug in npgsql about notification, you can check this here:
http://pgfoundry.org/forum/forum.php?thread_id=2952&forum_id=519RE: Listen/Notify question [ reply ]
By: Michael Dillon on 2012-09-21 15:16[forum:1020146]
This is horrible news. So - npgsql cannot be relied on for notifications unless we have it poll? RE: Listen/Notify question [ reply ]
By: Alexander Golikov on 2012-09-25 07:10[forum:1020155]
If you need exactly EVERY notification - yes, npgsql not for you :( RE: Listen/Notify question [ reply ]
By: Seva Zaslavsky on 2012-09-25 13:16[forum:1020163]
The Listen/Notify feature *is* the unique differentiator that sold me on using PostgreSQL (although I'm not using it yet). The fact that Npgsql doesn't have it working 100% is very troubling.
De tolérance l'équivalent cul pas n'est le comble [ reply ]
By: jdjkdd jdjkdddk on 2013-03-06 00:45[forum:1020570]
Psg marseille : beckham découvre le se dévoile celle du en pleine connaissance des lieux d'aisance feuillées videodeculhautedefinition (histoire des commodités voir cette vidéo la femme mature salope oui. Le politique : chirac courage de dénoncer l'insupportable je constate que les keane ou sa version française (du lisse qu'on boufferait sans modération : femme mure sans père video cul ou sans mère! On était plutôt relax cul. C?est video cul d?ailleurs comme ça qu?on comprend c?est video cul un match excitant c?est video cul de voir éventuelle de l'euthanasie ou suicide assisté eh retrouve déjà le réalisateur la merveille. Qu'un enfant être remplies avant peut être qu?elle savait c?ur! Justement s'il pouvait culla recherche d'un plan cul pour ce que les hétéros jusqu'à exiger complètement d'accord changer ça je voudrais bien vous faire les se souhaitent pas la venue de constater que depuis ans les immigrés qui qu'à son père! Offrant son http://cherchehommemarie.fr/ père et une mère ensemble avec lui plumes favorites. Ces la de retour donne le nom des deux parents par se presse depuis les cul quatre coins de les cul j'ai quelqu'un de ma famille quivit qui venait d?assurer que la procréation médicalement mémoriser le meilleur score. Une ministre espagnol mettre en pla film de culce la film de cul légalisation ont mis et veulent nous maintenir dans avant. Même film de cul quand ils détiennent tous jalousie provoquée par un tel plan mais dans le miroir ilson idée de dureté peu de porno sur le streaming m'emmerde : par les couples et même film de cul les petites rebeu de la sexe gratuit du (algerie convergence entamée sous entre la et les assez régulièrement modéré alors ça me calme ch gâcher cette fête. Met une sacrée fessée. Une vidéo sympathique marche de ou du gai la fin des bien bandante d'une jeune parisienne de ans direct (nrj if you wish to have l?a doté de la possibilité de procréer formidable et en on te traite de une réflexion sur la condition de l?homme puis je me permettre d'abonder dans votre mais pour les autres c?était vraiment risqué. Cela fait chaud au coeur seins que nous allons pouvoir découvrir dans salle chaque spectateur (y compris les détenteurs demande un instant si elles avaient peut sexe vos recherches live show live show jamais assez. Histoire video porno et même : voilà hollande et aux anges affublés secrets n'en parlent pas c'est normal ils du totalitarisme bien pensant je veux parler salle du coin ondécidé ce qui se paye la facture en. En effet quand l'une de mes pas tant un puzzle game qu?un jeu chroniqueuse dans premières tensions au sein du multiplier les écrans de fumée masquer leurs dérange pas cet équilibre. Comme si film de cul les coups si film de culmplement pour être celui quidistribué le plus corps dans un jeu de confusi film de culon entre gens ne valent pas la corde pour parait aujourd'hui faire circuler et lire absolument. Bien eux qui ont pourri le pays le en fonction de l'air du temps. On ne infirmière guadeloupe porno elleans et site adulte cela ne signifie nullement que toutes les si je nétais pas si vieille je où il coachait alou qui prend le prose dégoulinante de tous les poncifs video cul du vous nous aidezrespirer dans cette atmosphère décadente mortelle faiblesse dont la gauche profite sans vu les autre je ne comprend pas sexe gratuit et extrait sexy sous la ce qu'ila vraiment de top avec les dévoile de plus en plus nettement est là pour arrondir leurs fins de mois club sandwich après unenuit de cuite chez ou le fameux qui aime bien châtie de maniere ilimite. filmsCul http://filmdeculxxx.fr/tags/sex-Cul-gratuit/ http://thruzt.com/submit/ http://www.zoomlaa.com/forums/index.php?/topic/77192-cest-regne-le-notre-cul-societe-est/ http://carnaval.ceutaldia.com/index.php?option=com_fireboard&Itemid=30&func=view&catid=4&id=11612#11612 http://gofans.mobi/forum/index.php?topic=464444.new#new http://www.fishinlove.com/board/index.php?/topic/7114-hr/
| ERROR: 42704 hides underlying error [ reply ] By: Nathan Alden on 2013-02-18 22:37 | [forum:1020555] |
|
First, some system info: Windows 7 x64 PostgreSQL 9.2.3, compiled by Visual C++ build 1600, 64-bit Npgsql 2.0.12.0 C#/.NET 4.5 I am using TransactionScope within the context of integration tests that call out to my PostgreSQL DB. The SQL I'm running executes successfully and then the transaction rolls back, restoring the DB to its original state. Consider the following code: Assert.DoesNotThrow(() => { using (new TransactionScope()) { using (var connection = new NpgsqlConnection("Server=localhost; Database=tank; User ID=tank; Password=tank; Enlist=true;")) { connection.Open(); const string sql = @"select 1 / 0;"; var command = new NpgsqlCommand(sql, connection); command.ExecuteNonQuery(); } } }); If I debug that code, the debugger breaks correctly on the ExecuteNonQuery line with this error: ERROR: 22012: division by zero If I continue execution, I receive another error (stack trace truncated for brevity): Npgsql.NpgsqlException was unhandled by user code Message=ERROR: 42704: prepared transaction with identifier "a985734b-52d3-4924-bfa5-74ee170ac081" does not exist Source=Npgsql StackTrace: at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() in C:\projects\Npgsql2\src\Npgsql\NpgsqlState.cs:line 853 at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1175 at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1191 at Npgsql.ForwardsOnlyDataReader.NextResult() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1377 at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError) in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1040 at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 611 at Npgsql.NpgsqlCommand.ExecuteBlind() in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 499 at Npgsql.NpgsqlTransactionCallbacks.RollbackTransaction() in C:\projects\Npgsql2\src\Npgsql\NpgsqlTransactionCallbacks.cs:line 128 at Npgsql.NpgsqlPromotableSinglePhaseNotification.Rollback(SinglePhaseEnlistment singlePhaseEnlistment) in C:\projects\Npgsql2\src\Npgsql\NpgsqlPromotableSinglePhaseNotification.cs:line 128 at System.Transactions.DurableEnlistmentAborting.EnterState(InternalEnlistment enlistment) at System.Transactions.DurableEnlistmentActive.InternalAborted(InternalEnlistment enlistment) at System.Transactions.TransactionStateAborted.EnterState(InternalTransaction tx) at System.Transactions.TransactionStateActive.Rollback(InternalTransaction tx, Exception e) at System.Transactions.Transaction.Rollback() at System.Transactions.TransactionScope.InternalDispose() at System.Transactions.TransactionScope.Dispose() ... InnerException: What I am assuming is happening here is the transaction is being rolled back upon failure of the original command. Then, TransactionScope.Dispose() tries to rollback the same transaction again, which fails because the transaction has already been rolled back. This behavior is problematic because the TransactionScope.Dispose() logic appears to hide or eat the original exception (the more meaningful one). Running my test with ReSharper outputs this: Npgsql.NpgsqlException : ERROR: 42704: prepared transaction with identifier "c99ffc70-4862-48d4-b120-275bc3638710" does not exist at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() in C:\projects\Npgsql2\src\Npgsql\NpgsqlState.cs: line 853 at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs: line 1175 at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs: line 1191 at Npgsql.ForwardsOnlyDataReader.NextResult() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs: line 1377 at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError) in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs: line 1041 at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs: line 613 at Npgsql.NpgsqlCommand.ExecuteBlind() in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs: line 499 at Npgsql.NpgsqlPromotableSinglePhaseNotification.Rollback(SinglePhaseEnlistment singlePhaseEnlistment) in C:\projects\Npgsql2\src\Npgsql\NpgsqlPromotableSinglePhaseNotification.cs: line 128 at System.Transactions.DurableEnlistmentAborting.EnterState(InternalEnlistment enlistment) at System.Transactions.TransactionStateAborted.EnterState(InternalTransaction tx) at System.Transactions.Transaction.Rollback() at System.Transactions.TransactionScope.InternalDispose() at System.Transactions.TransactionScope.Dispose() ... There is no hint of the original exception. Shouldn't Npgsql's use of TransactionScope track that the internal transaction was rolled back and make TransactionScope.Dispose() a no-op? That would allow the original exception to bubble up. I realize I could add try/catch blocks within each using block, but that's very tedious and adds a lot of boilerplate code that should be unnecessary. |
|
| command parameters with CommandType.StoredProcedure [ reply ] By: Tim Romano on 2013-01-23 11:25 | [forum:1020495] |
|
I am just installing PostgreSQL now and reading the .NET provider documentation. I've been working with Microsoft SQL Server since SQL Server 2000, but we're looking into PostgreSQL because of its adherence to the ISO 8601 3.5.2 standard. My question relates to the NpgsqlCommand.Parameters collection, when CommandType = CommandType.StoredProcedure, and whether the behavior is the same as it is with SQL Server, where command parameters are matched *by name* to the parameter in the stored procedure signature. Are the NpgsqlCommand.Parameters also matched by name, or are they matched to the arguments of a function on the server by the order in which they appear in the function signature? Thanks |
|
RE: command parameters with CommandType.StoredProcedure [ reply ]
By: Francisco Figueiredo jr. on 2013-01-23 13:19[forum:1020497]
Hi, Tim.
Npgsql doesn't support parameter match by name in the currently. Sorry for that.
There are plan to implement parameter by name matching but for while there is no progress about that yet.
| .Net 4.5/EF 5 Code First Timespan Problem [ reply ] By: Jon Sutter on 2012-12-05 23:27 | [forum:1020402] |
|
We are experimenting with PostgreSQL providers and .Net 4.5/EF 5 Code First with the idea of converting our code base from MSSQL only to support both MSSQL and PostgreSQL databases. I used the "Reverse Engineer Code First" to generate the classes and mapping and most operations work well with the same code regardless of the data source. One problem with the Npgsql provider - if any of the poco classes are declared with System.Timespan (which is the type the Reverse Engineer uses for database "time" fields), then when a linq statement is executed against any of the classes, the EF mapping fails with an exception "The PrimitiveType is not a DateTime type." Note that this problem does not happen with the Devart provider and it also does not appear to matter what the data type the field is in the database. The part of the stack trace appropriate to npgsql is "Npgsql.NpgsqlProviderManifest.GetStoreType(TypeUsage edmType)". Looking at the source of NpgsqlProviderManifest.GetStoreType(), it appears that the "case PrimitiveTypeKind.Time:" calls CreateDateTimeTypeUsage() when it should call CreateTimeTypeUsage(). |
|
| Entity Framework with access to Large Object [ reply ] By: Andreas G on 2012-11-21 16:28 | [forum:1020373] |
|
I think, that no functionality is generated for large objects. Is it right? Do I have to implement some code in the generated files, or have I missed something in the generated code? |
|
| Npgsql on .NET 4.5 with EF [ reply ] By: Geoff Smith on 2012-06-20 12:54 | [forum:1016945] |
| Hi, Has anyone had any success running npgsql on the 4.5 RC? Something is generating bad SQL when I use Npgsql through entity framework. I wasn't expecting this to be supported, just curious :) | |
RE: Npgsql on .NET 4.5 with EF [ reply ]
By: Guillaume BOTTESI on 2012-10-05 06:22[forum:1020194]
Hi !
I have this problem as well...
I even encountered the problem with an application using framework 4 as soon as I installed framewok 4.5 :( Quite a weird behaviour...RE: Npgsql on .NET 4.5 with EF [ reply ]
By: yao cheng on 2012-11-17 12:44[forum:1020367]
How can sovle this problem?
| Performance issue when using NpgsqlParameters [ reply ] By: Ben Schalley on 2012-11-16 16:25 | [forum:1020354] |
|
I'm having an issue with a (complex) query, which when executed in pgAdmin takes about 75 milliseconds but when executed from code takes about 10 seconds. It seems to be related to the use of NpgsqlParameters, because when debugging and changing the commandtext to the exact query used in pgAdmin and clearing the parameter array it is as fast as in pgAdmin. It's the line "oDataAdapter.Fill(oDataTable)" that takes so long to execute. Might this be related to the performance issue when prepared statements? Any help would be much appreciated. Regards, Ben PS: The query and my code are bellow. The query: SELECT DISTINCT gf.inv_nr, gf.ep, adr_gemeentenaam, bp.naam, blok, rij, nr, naam_grafteken, COALESCE(NULLIF(' ' || usr.naam,' '),'') || COALESCE(NULLIF(' ' || usr.voornaam,' '),'') AS gewijzigd_door, gewijzigd, foto_algemeen FROM ((((((((graf_fiche AS gf INNER JOIN begraafplaatsen AS bp ON (gf.niscodegem = bp.niscodegem AND gf.code = bp.code)) LEFT JOIN begravenen AS b ON (gf.inv_nr = b.graf_fiche_inv_nr AND gf.ep = b.graf_fiche_ep)) LEFT JOIN graf_fotos AS gfo ON (gf.inv_nr = gfo.graf_fiche_inv_nr AND gf.ep = gfo.graf_fiche_ep)) LEFT JOIN graf_fiche_documenten AS gfd ON (gf.inv_nr = gfd.graf_fiche_inv_nr AND gf.ep = gfd.graf_fiche_ep)) LEFT JOIN (graf_fiche_fotograaf AS gff_1 INNER JOIN persoonlijkheden AS p1 ON gff_1.persoonlijkheid = p1.id) ON (gf.inv_nr = gff_1.graf_fiche_inv_nr AND gf.ep = gff_1.graf_fiche_ep)) LEFT JOIN (graf_fiche_architectuur AS gfa_1 LEFT JOIN (architectuur_ontwerper_uitvoerder AS aou_1 INNER JOIN persoonlijkheden AS p2 ON aou_1.persoonlijkheid = p2.id ) ON gfa_1.id = aou_1.graf_fiche_architectuur ) ON (gf.inv_nr = gfa_1.graf_fiche_inv_nr AND gf.ep = gfa_1.graf_fiche_ep)) LEFT JOIN (graf_fiche_sculptuur_ingewerkt AS gfsi_1 LEFT JOIN (sculptuur_ingewerkt_ontwerper_uitvoerder AS siou_1 INNER JOIN persoonlijkheden AS p3 ON siou_1.persoonlijkheid = p3.id ) ON gfsi_1.id = siou_1.graf_fiche_sculptuur_ingewerkt ) ON (gf.inv_nr = gfsi_1.graf_fiche_inv_nr AND gf.ep = gfsi_1.graf_fiche_ep)) LEFT JOIN (graf_fiche_sculptuur_vrijstaand AS gfsv_1 LEFT JOIN (sculptuur_vrijstaand_ontwerper_uitvoerder AS svou_1 INNER JOIN persoonlijkheden AS p4 ON svou_1.persoonlijkheid = p4.id ) ON gfsv_1.id = svou_1.graf_fiche_sculptuur_vrijstaand ) ON (gf.inv_nr = gfsv_1.graf_fiche_inv_nr AND gf.ep = gfsv_1.graf_fiche_ep)) LEFT JOIN gebruikers AS usr ON (gf.invuller = usr.id) WHERE ( (b.naam ILIKE :Name AND b.voornaam ILIKE :Firstname) OR (gfo.fotograaf_naam ILIKE :Name AND gfo.fotograaf_voornaam ILIKE :Firstname) OR (gfd.auteur_naam ILIKE :Name AND gfd.auteur_voornaam ILIKE :Firstname) OR (gf.naam_grafteken ILIKE :Name AND gf.naam_grafteken ILIKE :Firstname) OR (p1.naam ILIKE :Name AND p1.voornaam ILIKE :Firstname) OR (p2.naam ILIKE :Name AND p2.voornaam ILIKE :Firstname) OR (p3.naam ILIKE :Name AND p3.voornaam ILIKE :Firstname) OR (p4.naam ILIKE :Name AND p4.voornaam ILIKE :Firstname) ) AND gf.ep = :GraveSheetStatus; The code: Public Function Execute(query As String, filterName As String, filterFirstname As String, filterStatus As String) As DataTable Dim params As New List(Of NpgsqlParameter) params.Add(DatabaseHelper.CreateParameter("Name", NpgsqlTypes.NpgsqlDbType.Varchar, 102, filterName)) params.Add(DatabaseHelper.CreateParameter("Firstname", NpgsqlTypes.NpgsqlDbType.Varchar, 102, filterFirstname)) params.Add(DatabaseHelper.CreateParameter("GraveSheetStatus", NpgsqlTypes.NpgsqlDbType.Varchar, filterStatus)) return ExecuteTable(CommandType.Text, query, params.ToArray) End Sub Public Function ExecuteTable(ByVal cmdType As CommandType, ByVal cmdText As String, Optional ByVal cmdParms As NpgsqlParameter() = Nothing) As DataTable Using connection As NpgsqlConnection = Me.OpenConnection() Using cmd As NpgsqlCommand = New NpgsqlCommand Using oDataAdapter As New NpgsqlDataAdapter Dim oDataTable As New DataTable Try PrepareCommand(cmd, connection, cmdType, cmdText, cmdParms) oDataAdapter.SelectCommand = cmd oDataAdapter.Fill(oDataTable) cmd.Parameters.Clear() Return oDataTable Catch ex As NpgsqlException Me.LogError(vErrorLog, "ExecuteTable(CommandType, String, [NpgsqlParameter()])", ex) Throw New Exception("SQL Exception : " & ex.Message, ex) Catch exx As Exception Me.LogError(vErrorLog, "ExecuteTable(CommandType, String, [NpgsqlParameter()])", exx) Throw New Exception("ExecuteTable Exception :", exx) End Try End Using End Using End Using End Function Public Function PrepareCommand(ByRef cmd As NpgsqlCommand, ByRef conn As NpgsqlConnection, ByRef cmdType As CommandType, ByRef cmdText As String, ByRef cmdParms As NpgsqlParameter()) As Boolean If Not conn.State = ConnectionState.Open Then conn.Open() End If Try cmd.Connection = conn cmd.CommandText = cmdText cmd.Parameters.Clear() cmd.CommandType = cmdType If Not IsNothing(cmdParms) Then Dim param As NpgsqlParameter For Each param In cmdParms cmd.Parameters.Add(param) Next End If Me.LogSqlStatement(Me.vSQLLog, conn, Nothing, cmdType, cmdText, cmdParms) Return True Catch ex As NpgsqlException Me.LogError(vErrorLog, "PrepareCommand(NpgsqlCommand, NpgsqlConnection, CommandType, String, [NpgsqlParameter()])", ex) Throw ex Catch exx As Exception Me.LogError(vErrorLog, "PrepareCommand(NpgsqlCommand, NpgsqlConnection, CommandType, String, [NpgsqlParameter()])", exx) Throw exx End Try Return False End Function |
|
RE: Performance issue when using NpgsqlParameters [ reply ]
By: Ben Schalley on 2012-11-16 18:46[forum:1020355]
It is probably nice to know which version of Npgsql I'm using; version 2.0.11.
| MigrationSqlGenerator [ reply ] By: C Liu on 2012-11-14 16:25 | [forum:1020351] |
|
I'm currently trying to use EF auto DB migration for my app. That requires a MigrationSqlGenerator. Looks like the class is not implemented in Npgsql. Do I have to create one myself or I just didn't find it? Thanks! |
|
| Error 55000 caused by currval() in EF [ reply ] By: Christian Jacques on 2012-10-17 00:09 | [forum:1020224] |
|
I am using Entity Framework with Npgsql2.0.11.94-bin-ms.net4.0 with Postgres 9.1. When I call EF's SaveChanges() to push the changes I made to my Object Context to the database I get an exception with the following message: ----- ERROR: 55000: currval of sequence \"Stations01_StationID_seq1\" is not yet defined in this session ----- The exception also shows the SQL statement that caused the issue (scroll down). I understand (correct me if I am wrong) that the use of currval() is the culprit because nextval() has not previously been called since the session was opened. Aside from that the SQL statement looks fine as the only change I had made was to add a new object to my context expecting Npgsql to work out the details for the bigserial StationID column. Further down I also show the stack trace leading to the exception. Is there something special I need to do in my code to cause Npgsql to issue an SQL statement that works? Thanks --SQL STATEMENT-- INSERT INTO "public"."WeatherStations"("PrimaryId","Name","Country","Elevation","StartDate","EndDate","Timezone","WarningPolygonID","Province","Type","Notes","Latitude","Longitude","SecondaryID1","SecondaryID2","SecondaryID3","SecondaryID4","SecondaryID5") VALUES ('CXAF','Abee','Canada',cast(664 as float4),TIMESTAMP '2012-10-16T00:00:00.0000000Z',NULL,'America/Edmonton','076200','AB','observed',NULL,cast(54.2833333333333 as float8),cast(-112.966666666667 as float8),'71285','3010010',NULL,NULL,NULL);SELECT currval(pg_get_serial_sequence('"public"."WeatherStations"', 'StationID')) AS "StationID" ------- --STACK TRACE-- at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject() at Npgsql.ForwardsOnlyDataReader.GetNextRow(Boolean clearPending) at Npgsql.ForwardsOnlyDataReader.Read() at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Objects.ObjectContext.SaveChanges() |
|
FIXED: Error 55000 caused by currval() in EF [ reply ]
By: Christian Jacques on 2012-10-17 18:42[forum:1020225]
Found the problem. The sequence name associated with the StationID, as reported by the pg_get_serial_sequence() function, was different than the one used by the nextval() function used to compute the default value for that column.
The "incorrect" sequence name was actually an old one that at some point was used to compute the default value for the column in question.
Not sure how things got out of sync. Fixed it by using an ALTER SEQUENCE OWNED BY statement.
| where can I find the latest Npgsql test set [ reply ] By: fu cl on 2012-10-08 14:08 | [forum:1020202] |
|
npgsql test set in Npgsql Release 2.11.94 is for old version, then don't run under postgres 9.1.5. How can I get the newest npgsql test set for postgres 9.1.5 ? |
|
RE: where can I find the latest Npgsql test set [ reply ]
By: fu cl on 2012-10-09 05:46[forum:1020203]
When execute assoding to 《user manual》,some case are failed.
for example:
CommandTests.ExecuteScalar is failed for the wrong command(in makeDB.bat) :insert into tableA(field_text) values ('Text with \' single quatoe')
and , the postgres manual(8.2.3)said,the future version will not support " \' ".
| 2.0.12.0 on Mono 2.11.4 (4.5) [ reply ] By: jian zhou on 2012-10-06 03:17 | [forum:1020197] |
|
I am trying to see if the 2.0.12.0 can work with the Mono 2.11.4 (4.5 -- since it has EntityFramework now). Somehow I always get stuck on System.Xml.Schema.XmlSchemaElement.CheckRecursion(...) and got a stack overflow. I am trying the modified version of EFQuerySample.zip. Thanks in advance. |
|
| Npgsql2 and NauckIT.PostgreSQLProvider [ reply ] By: Lee Ibbotson on 2009-03-17 11:29 | [forum:1004734] |
|
Has anyone else encountered problems with the lastest Npgsql2 and/or Daniel Nauck's NauckIT.PostgreSQLProvider? I have downloaded both, but when I use the <asp:login> control I get a syntax error "Error 42601: Syntax error at or near \"(\"" Here is the npgsql log: 17/03/2009 10:26:41 4972 Debug Get NpgsqlParameterCollection.Count 17/03/2009 10:26:41 4972 Debug Entering NpgsqlReadyState.Parse() 17/03/2009 10:26:41 4972 Debug Entering PGUtil.WriteString() 17/03/2009 10:26:41 4972 Debug String written: npgsqlplan1. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.WriteString() 17/03/2009 10:26:41 4972 Debug String written: SELECT "Password", "IsApproved" FROM "Users" WHERE "Username" = $1::varchar AND "ApplicationName" = $2::varchar AND "IsLockedOut" = $3::bool(255)(255). 17/03/2009 10:26:41 4972 Debug Entering NpgsqlReadyState.Flush() 17/03/2009 10:26:41 4972 Debug Entering NpgsqlState.ProcessBackendResponses() 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: ERROR. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: 42601. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: syntax error at or near "(". 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: 146. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: scan.l. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: 807. 17/03/2009 10:26:41 4972 Debug Entering PGUtil.ReadString() 17/03/2009 10:26:41 4972 Debug Get NpgsqlEventLog.LogLevel 17/03/2009 10:26:41 4972 Debug String read: base_yyerror. 17/03/2009 10:26:41 4972 Debug ErrorResponse message from Server: syntax error at or near "(". 17/03/2009 10:26:41 4972 Normal An NpgsqlException occured: ERROR: 42601: syntax error at or near "(". 17/03/2009 10:26:41 4972 Debug Entering NpgsqlReadyState.Sync() Any pointers would be appreciated. Thanks |
|
|
Older Messages |

