Inserting new collection using xml files

Posts   
 
    
olav78
User
Posts: 8
Joined: 14-Jun-2007
# Posted on: 14-Jun-2007 15:20:33   

Hello!

We generate some xml-files from a llblgen project using the self servicing template group, and send them to a client with no access to the underlying db. The xml files are then regenerated as llblgen objects on the client side (the client has access to the llblgen generated libs).

One of the files are called CargoOperations.xml consisting of a serialized CargoOperationCollection. I want to put a new CargoOperationEntity into this collection. The problem is that a CargoOperationEntity has one NorTenderedCollection. To insert a new NorTenderedCollection into a new CargoOperationEntity i try to do this:

CargoOperationEntity coe = new CargoOperationEntity(); NorTenderedEntity nor = new NorTenderedEntity(); coe.NorTendered.Add(nor);

But i get an error because the connectionString is not initialized...

I've also tried this:

CargoOperationEntity coe = new CargoOperationEntity(); NorTenderedEntity nor = new NorTenderedEntity(); NorTenderedCollection nors = new NorTenderedCollection(); nors.Add(nor); coe.NorTendered = nors;

But now I get an “(NorTendered) property is read only”...

I can add a CargoOperationEntity to one NorTenderedEntity (nor.CargoOperation = coe), but then I got to send a new xml-file back to the server to update the db, and we don't want too many xml files (we have more issues of the same sort)...

  • Olav
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Jun-2007 15:29:01   

To insert a new NorTenderedCollection into a new CargoOperationEntity i try to do this:

CargoOperationEntity coe = new CargoOperationEntity(); NorTenderedEntity nor = new NorTenderedEntity(); coe.NorTendered.Add(nor);

Please post the complete real code, as the above 2 entities won't be saved to the database since there are no fields set ith values.

But i get an error because the connectionString is not initialized...

Where do you get this error, on the client side or back on the server side when you save the entity.

Please post the complete exception text and stack trace.

Thanks.

olav78
User
Posts: 8
Joined: 14-Jun-2007
# Posted on: 14-Jun-2007 16:00:28   

Oh, sorry.


CargoOperationEntity coe = new CargoOperationEntity();
coe.CargoCalculationCompleted = DateTime.Now;
NorTenderedEntity nor = new NorTenderedEntity();
nor.NorTendered = DateTime.Now;
nor.CargoOperation = coe;
coe.NorTendered.Add(nor);

This is on the client (without access to the db). The last line gives this exeption:


System.InvalidOperationException was unhandled
  Message="Egenskapen ConnectionString er ikke initialisert.***"
  Source="System.Data"
  StackTrace:
       ved System.Data.SqlClient.SqlConnection.PermissionDemand()
       ved System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
       ved System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       ved System.Data.SqlClient.SqlConnection.Open()
       ved SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery)
       ved SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)
       ved JoTankers.JoSof.DAO.DaoClasses.NorTenderedDAO.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicateExpression filter, IEntity cargoOperationInstance, Int32 pageNumber, Int32 pageSize)
       ved JoTankers.JoSof.DAO.CollectionClasses.NorTenderedCollection.GetMultiManyToOne(IEntity cargoOperationInstance, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicateExpression filter, Int32 pageNumber, Int32 pageSize)
       ved JoTankers.JoSof.DAO.CollectionClasses.NorTenderedCollection.GetMultiManyToOne(IEntity cargoOperationInstance, IPredicateExpression filter)
       ved JoTankers.JoSof.DAO.EntityClasses.CargoOperationEntity.GetMultiNorTendered(Boolean forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
       ved JoTankers.JoSof.DAO.EntityClasses.CargoOperationEntity.GetMultiNorTendered(Boolean forceFetch)
       ved JoTankers.JoSof.DAO.EntityClasses.CargoOperationEntity.get_NorTendered()
       ved TestConsole.Program.test() i C:\Documents and Settings\Administrator\Mine dokumenter\Visual Studio 2005\Projects\JoSof\TestConsole\Program.cs:linje 53
       ved TestConsole.Program.Main(String[] args) i C:\Documents and Settings\Administrator\Mine dokumenter\Visual Studio 2005\Projects\JoSof\TestConsole\Program.cs:linje 21
       ved System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       ved System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       ved Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       ved System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       ved System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       ved System.Threading.ThreadHelper.ThreadStart()


***"Egenskapen ConnectionString er ikke initialisert." = The property ConnectionString is not initialized.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Jun-2007 16:04:02   

That's because you are using SelfSrvicing, while you should have used the Adapter model, if you send your entities over the wire.

coe.NorTendered.Add(nor);

Lazy Loading tries to fetch the NorTendered collection when you call the above line.

olav78
User
Posts: 8
Joined: 14-Jun-2007
# Posted on: 14-Jun-2007 16:08:43   

Thanks a lot smile !