Sure!
In the client I call the first method and then pass the same dataset to all
the rest.
public DataSet GetDataSet(string sql)
{
DataSet dataSet=new DataSet();
using(OracleConnection connection=new OracleConnection("...."))
{
connection.Open();
OracleDataAdapter adapter=new OracleDataAdapter(sql, connection);
adapter.Fill(dataSet, "A");
return dataSet;
}
}
public void GetDataSet(string sql, DataSet dataSet)
{
if(dataSet==null) throw new ArgumentNullException("dataset", "que
hace!!");
using(OracleConnection connection=new OracleConnection("..."))
{
connection.Open();
OracleDataAdapter adapter=new OracleDataAdapter(sql, connection);
adapter.Fill(dataSet, "B");
}
}
public DataSet GetDataSet(DataSet dataSet, string sql)
{
if(dataSet==null) throw new ArgumentNullException("dataset", "que
hace!!");
using(OracleConnection connection=new OracleConnection("..."))
{
connection.Open();
OracleDataAdapter adapter=new OracleDataAdapter(sql, connection);
adapter.Fill(dataSet, "C");
}
return dataSet;
}
public void GetDataSet(string sql, ref DataSet dataset)
{
GetDataSet(sql, dataset);
}
> Can you paste the code for
>
[quoted text clipped - 46 lines]
> > Ariel Popovsky
> > Buenos Aires, Argentina
Ken Kolda - 28 Jun 2004 18:17 GMT
The DataSet is a serializable, non-MarshalByRefObject-derived class so when
it crosses the remoting layer it gets serialized/deserialized and the
receiving end has its own copy (as if it were a value type). Thus, changes
to the object will not be seen by the caller unless, as you noted, you mark
the parameter with "ref" or "out" (which tells the remoting interfaces to
remote the object back when the call completes).
Do your business objects derive (directly or indirectly) from
MarshalByRefObject? If so, that would explain why they work as you expect --
but it also means that every property/method call is crossing the remoting
channel (could be expensive if it's not what you intend).
Ken
> Sure!
> In the client I call the first method and then pass the same dataset to all
[quoted text clipped - 101 lines]
> > > Ariel Popovsky
> > > Buenos Aires, Argentina
Ariel Popovsky - 29 Jun 2004 00:31 GMT
I thought something like that, I believe it has to be something about the
way DataSets are serialized. Maybe it get passed as plain XML (BTW, I'm
using a BinaryFormatter through a tcp channel).
My business object is very simple, just a couple of fields and it doesn't
extend any other class. It's just marked with the SerializableAttribute.
Thanks for the answers!
Ariel
> The DataSet is a serializable, non-MarshalByRefObject-derived class so when
> it crosses the remoting layer it gets serialized/deserialized and the
[quoted text clipped - 9 lines]
>
> Ken
Ken Kolda - 29 Jun 2004 01:35 GMT
You're saying you can pass a serializable business object to a remote system
without using "ref" or "out" and the caller can see the changes made to the
object? That goes against how I understand that remoting works -- you may
want to verify this behavior before you build to much dependence on this
behavior.
A couple of other things to note:
1. The DataSet does serialize itself as XML, but that's really
inconsequential to what you're seeing. The manner in which the object is
serialized (whether it just uses the default serialization provided by
[Serializable] or implements its own using ISerializable) has no effect on
whether you will see changes made in the remoted object. Any object that's
not MBR and is serializable will be passed with value-type sematics across
remoting interfaces.
2. The formatter/channel also make no difference to the logical sematics of
remoting. The DataSet will serialize itself to XML regardless of the
channel/formatter type being used -- it doesn't know or care what type of
envelope the remoting infrastructure is going to wrap it in. Using a binary
formatter just means that once the DataSet generates its XML, it is binary
encoded along with the remoting header info and sent across the wire. If you
were using SOAP, the XML would be wrapped in a SOAP-formatted package.
Either way, the formatter on the other end knows how to restore the XML to
its original form so that when the DataSet deserializes it has the correct
data.
Ken
> I thought something like that, I believe it has to be something about the
> way DataSets are serialized. Maybe it get passed as plain XML (BTW, I'm
[quoted text clipped - 21 lines]
> >
> > Ken
Ariel Popovsky - 30 Jun 2004 00:01 GMT
You were right Ken, there was an error in my test application. I was writing
to the console some field values from the server, where the BO was modified
and not from the client after the method returned. I added a new output to
the client and found that the behaviour is consistent, when I use ref, the
modifications made by the server can be seen in the client, otherwise they
don't.
Thanks!
Ariel
> You're saying you can pass a serializable business object to a remote system
> without using "ref" or "out" and the caller can see the changes made to the
[quoted text clipped - 53 lines]
> > >
> > > Ken