Search found 12 matches

by PatrickG
Fri 14 Dec 2012 23:59
Forum: dotConnect for PostgreSQL
Topic: DbContext template question
Replies: 2
Views: 1155

DbContext template question

I noticed an unexpected behaviour that I'm not sure if is by design or if it's a bug.

When I generate Entities using the POCO template I get objects based on ObjectContext. The generated entities have navigation properties that follow the pattern of:

Code: Select all

/// <summary>
/// There are no comments for MyItems in the schema.
/// </summary>
public virtual ICollection<MyItem> MyItems
{
    get
    {
      if (_MyItems == null)
      {
	  var newCollection = new FixupCollection<MyItem>();
	  newCollection.CollectionChanged += FixupMyItems;
	  _MyItems = newCollection;
      }
      return _MyItems;
    }
    set
    {
      if (!ReferenceEquals(_MyItems, value))
      {
	  var previousValue = _MyItems as FixupCollection<MyItem>;
	  if (previousValue != null)
	  {
	    previousValue.CollectionChanged -= FixupMyItems;
	  }
	  _MyItems = value;
	  var newValue = value as FixupCollection<MyItem>;
	  if (newValue != null)
	  {
	      newValue.CollectionChanged += FixupMyItems;
	  }
      }
    }
}
private ICollection<MyItem> _MyItems;

private void FixupMyItems(object sender, NotifyCollectionChangedEventArgs e)
{
  if (e.NewItems != null)
  {
      foreach (MyItem item in e.NewItems)
      {
	  item.ProductVersion = this;
      }
  }

  if (e.OldItems != null)
  {
      foreach (MyItem item in e.OldItems)
      {
	  if (ReferenceEquals(item.MyParent, this))
	  {
	      item.MyParent = null;
	  }
      }
  }
}

But if I use the DbContext template, then the navigation properties have a pattern of:

Code: Select all

/// <summary>
/// There are no comments for MyItems in the schema.
/// </summary>
public virtual ICollection<MyItem> MyItems
{
    get;
    set;
}      
   
The key for me is that if I have code such as:

Code: Select all

MyParent p = new MyParent() { Name = "Some Name" };
MyDbContext.Parents.Add(p);
p.MyItems.Add(new MyItem() { Quantity = 8} );
I get a null reference exception where I wouldn't have using the POCO template. Is this the intention?

Thanks,

Patrick
by PatrickG
Tue 13 Sep 2011 19:26
Forum: dotConnect for PostgreSQL
Topic: sorry, too many clients already
Replies: 8
Views: 2955

sorry, too many clients already - SSPI bug

I thought it was a debug/release problem initially, but it turned out to just be a problem when using SSPI / integrated security in my connection string. Connections in the pool are not being re-used. Each and every query executed creates a new connection in the pool until no more can be created, then the "sorry, too many clients already" exception is thrown.

Hope that helps, it is pretty easy to duplicate.
by PatrickG
Fri 09 Sep 2011 19:15
Forum: dotConnect for PostgreSQL
Topic: sspi
Replies: 59
Views: 7113

sspi

There seems to be an issue with connection pooling when using SSPI, so you might want to test that scenario. Se my post under "sorry, too many clients already"

Patrick
by PatrickG
Fri 09 Sep 2011 19:12
Forum: dotConnect for PostgreSQL
Topic: sorry, too many clients already
Replies: 8
Views: 2955

sorry, too many clients already - SSPI bug

It looks like the problem only occurs when using integrated security, so there must be some sort of bug in the SSPI implementation...


Patrick
by PatrickG
Fri 09 Sep 2011 17:47
Forum: dotConnect for PostgreSQL
Topic: sorry, too many clients already
Replies: 8
Views: 2955

sorry, too many clients already

I am getting the error "sorry, too many clients already" when running in release mode, but not debug mode.

I don't believe I should be getting this error at all because I have explicitly limited the connection pool size (50) and my postgresql.conf specifies max_connections to be 110.

Other than pdAdmin III, using 3 connections there are not any other connections to the database.

I am using the following connection string:
Host=127.0.0.1;Port=5432;Database=my_database;Unicode=True;Integrated Security=True;Max Pool Size=50;Pooling=True;


When I query pg_stat_activity, the current connections does get up to 110, then my application errors out with the previously stated error. All of the connections are idle, and every PgSqlConnection I call is in a using. So I am at a loss for what I could be doing wrong here.

Any suggestions?

Thanks,

Patrick
by PatrickG
Fri 29 Jul 2011 18:26
Forum: dotConnect for PostgreSQL
Topic: Linq error
Replies: 8
Views: 1394

This does fix my problem, thank you.

It seems that this might have been a change from .Net 3.5 to .Net 4 as the same code fails in LinqToObjects and it used to work, at least in LinqToSql. Of course I converted my project to .Net 4 at the same time I am trying to convert to PostgreSQL and the invalid cast exception didn't seem to indicate that a null value was the problem...

Thanks again,

Patrick
by PatrickG
Wed 27 Jul 2011 23:35
Forum: dotConnect for PostgreSQL
Topic: Linq error
Replies: 8
Views: 1394

Here is a snippet of the code and and observation I was able to make...

Code: Select all

var baseQuery = from c in this.vwConfiguration
		where c.ConfigurationType.Equals(configurationType) && c.IsExpired.Equals(0)
		select c;

baseQuery = from c in baseQuery where c.SiteUID == null select c;

var q = from c in baseQuery
	where ((string.IsNullOrEmpty(product) && c.Product == null) || c.Product.Equals(product)) &&
	c.SiteUID.Equals(null) &&
	((string.IsNullOrEmpty(application) && c.Application == null) || c.Application.Equals(application))
	select c;
At this point q.Count or q.SingleOrDefault will throw the previously posted exception.


Interestingly enough if I comment out the line that checks to see if c.SiteUID is null, the query executes fine.

Code: Select all

var q = from c in baseQuery
	where ((string.IsNullOrEmpty(product) && c.Product == null) || c.Product.Equals(product)) &&
	//c.SiteUID.Equals(null) &&
	((string.IsNullOrEmpty(application) && c.Application == null) || c.Application.Equals(application))
	select c;
Note that SiteUID is of type System.Nullable
by PatrickG
Tue 26 Jul 2011 15:45
Forum: dotConnect for PostgreSQL
Topic: Linq error
Replies: 8
Views: 1394

Linq error

I am having some trouble when generating a linq query against the results of a prior linq query.

The exception that I get is:
System.InvalidCastException was unhandled
Message=Unable to cast object of type 'Devart.Data.Linq.Provider.ProviderType' to type 'Devart.Data.PostgreSql.Linq.Provider.PgSqlProviderType'.
Source=Devart.Data.PostgreSql.Linq
StackTrace:
at Devart.Data.PostgreSql.Linq.Provider.Query.a.a(ProviderType A_0, ProviderType A_1)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.TranslateToServerMethod(List`1 serverMethods, List`1 largeProviderTypes, List`1 arguments, Type returnType)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitMethodCall(bd mc)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitExpression(SqlExpression exp)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitBinaryOperator(av bo)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitBinaryOperator(av bo)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitExpression(SqlExpression exp)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitBinaryOperator(av bo)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitBinaryOperator(av bo)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitExpression(SqlExpression exp)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSelectCore(SqlSelect select)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitSelect(SqlSelect select)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSource(SqlNode source)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSelectCore(SqlSelect select)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitSelect(SqlSelect select)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSequence(SqlSelect sel)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitScalarSubSelect(ad ss)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSubSelect(ad ss)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitExpression(SqlExpression exp)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitRow(af row)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitSelectCore(SqlSelect select)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitSelect(SqlSelect select)
at Devart.Data.Linq.Provider.Query.SqlVisitor.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.DbMethodCallConverter.VisitAlias(e a)
at Devart.Data.Linq.Provider.Query.SqlVisitor.Visit(SqlNode node)
at Devart.Data.Linq.Provider.DataProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, IList`1 externalParameterAccessors)
at Devart.Data.Linq.Provider.DataProvider.BuildQuery(Expression query)
at Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.Execute(Expression query)
at Devart.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)

Is there any insight you can provide to help be diagnose this problem?

Patrick
by PatrickG
Fri 22 Jul 2011 22:17
Forum: dotConnect for PostgreSQL
Topic: DataContext ctor / iqml question
Replies: 3
Views: 1351

It turns out that was the problem, so thank you for you help with that. Still it would be nice if there were some documentation on the properties and attributes, there possible values and what it all means.

Patrick
by PatrickG
Thu 21 Jul 2011 20:19
Forum: dotConnect for PostgreSQL
Topic: DataContext ctor / iqml question
Replies: 3
Views: 1351

DataContext ctor / iqml question

Hello,

I'm looking for more information on iqml files. Currently when I try to create a new instance of a Devart.Data.Linq.DataContext object (ctor=DataContext(string connectionString, MappingSource mapping)), I get an exception. Unfortunately that exception doesn't contain any useful (to me) information about the problem. I'm guessing the problem is with my MappingSource, but I don't know what specifically is wrong with it.

The Exception that I get is:

System.ArgumentException was unhandled by user code
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Devart.Data.Linq.Mapping.MetaTypeBase.Initialize()
at Devart.Data.Linq.Mapping.aw.b()
at Devart.Data.Linq.Mapping.u.b()
at Devart.Data.Linq.Mapping.ay..ctor(MetaModel A_0, MetaTable A_1, ae A_2, Type A_3, MetaType A_4)
at Devart.Data.Linq.Mapping.u..ctor(av A_0, ak A_1, ae A_2, Type A_3)
at Devart.Data.Linq.Mapping.ak..ctor(av A_0, d A_1, Type A_2)
at Devart.Data.Linq.Mapping.av.b()
at Devart.Data.Linq.Mapping.av.e()
at Devart.Data.Linq.Mapping.av..ctor(MappingSource A_0, Type A_1, t A_2)
at Devart.Data.Linq.Mapping.XmlMappingSource.CreateModel(Type dataContextType)
at System.Data.Linq.Mapping.MappingSource.GetModel(Type dataContextType)
at Devart.Data.Linq.DataContext.a(Object A_0, MappingSource A_1, Type A_2)
at Devart.Data.Linq.DataContext..ctor(String connectionString, MappingSource mapping)

Is there any documentation on the requirements of an iqml file? In my case I am trying to convert an existing xml file generated by sqlmetal from a SQL Server database, so I think I must just be missing some value(s) that you require but LinqToSql and Sql Server do not.

Thank you,

Patrick
by PatrickG
Tue 07 Jun 2011 18:08
Forum: dotConnect for PostgreSQL
Topic: dotConnect 4.9.152 does not support CITEXT field
Replies: 8
Views: 1882

dotConnect 4.9.152 does not support CITEXT field

It has been almost 10 months since this post. I was wondering if there have been any changes to CITEXT support, or are any planned?

Patrick
by PatrickG
Thu 10 Mar 2011 22:02
Forum: dotConnect for PostgreSQL
Topic: sspi
Replies: 59
Views: 7113

sspi

It has been in available in PostgreSQL for a long time, it sure would be nice to be able to use this feature.

I too would like to be notified if and when this feature were to become available.

Thanks

Patrick