Hi I was searching for a long time for a OR-framework with linq support.

At the Time i am trying to get my own sample started. The project consists off only two classes: My Entity and another Form. But each time i want to save my object i get stackoverflowerrors....

Is there a really small sample for Do4.0 ? Because everything i downloaded is for 3.9....

Or can anyone help me with my code ?

private void Connect()
        {
            var config = DomainConfiguration.Load("mssql");
            config.Types.Register(Assembly.GetAssembly(typeof(AdressModel)), typeof(AdressModel).Namespace);
            domain = Domain.Build(config);
            domain.OpenSession();
            AdressModel hurz = new AdressModel();
            hurz.Phone = "123";
            hurz.Session.Persist();
        }

and my mapping code

[HierarchyRoot(typeof(KeyGenerator),"ID")]
    public class AdressModel : Entity
    {
        [Field]
        public long ID { get; private set; }

        [Field]
        public string Phone { get; set; }

        public static object AllAdresses()
        {
            var bla1 = from adressmodell in Query<AdressModel>.All
                   select adressmodell;
            return bla1;
        }
    }

Updated at 12.03.2009 8:56:47

Hi!

i don't think that it is an problem with DO. I don't get started with the samples you provide. Is there any very small sample on which i see the use of domain, session and transaction ?

The following code does not insert an Adress either :-/

var config = DomainConfiguration.Load("mssql");
            config.Types.Register(Assembly.GetAssembly(typeof(AdressModel)), typeof(AdressModel).Namespace);
            domain = Domain.Build(config);

            using (domain.OpenSession())
            {
                AdressModel hurz = new AdressModel();
                hurz.Phone = "123";
            }

DA gets an Connection to the Server, because the Tables have been generated...


Updated at 12.03.2009 9:41:07

ok, thanks, now i'am a step closer to the goal of my sample - inserting a phone number.

With the code you provided, the application inserts exactly one row - no matter how often i execute it. the inserted row contains an id , an typeid, but my value (phone number ) is null :-(

One question to the transaction scope,in the sample you ship with, the transaction scope isn't used and works fine? Why?

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by Jeb.

asked Mar 08 '09 at 12:16

Editor's gravatar image

Editor
46154156157

Alex Kofman wrote: Hello, Jeb

Try to use Session in a such way:

using (domain.OpenSession()) {
    AdressModel hurz = new AdressModel();
    hurz.Phone = "123";
}
(Mar 08 '09 at 12:16) Editor Editor's gravatar image

One Answer:

Alex (Xtensive) wrote:

And additionally:

  • You shouldn't call Session.Persist - consider this is for debugging or advanced users only

  • It's quite recommended to use transactions

  • We recommend to use the latest nightly build

  • Please publish a stack trace to get faster responses related to errors (or a recurring part of it for stack overflows).


Alex Kofman wrote:

Is there any very small sample on which i see the use of domain, session and transaction ?

Here it is:

var config = DomainConfiguration.Load("mssql");
            config.Types.Register(Assembly.GetAssembly(typeof(AdressModel)), typeof(AdressModel).Namespace);
            domain = Domain.Build(config);

            using (domain.OpenSession()) {
                using (var transactionScope = Transaction.Open()) {

                    AdressModel hurz = new AdressModel();
                    hurz.Phone = "123";

                    transactionScope.Complete();
               }
            }

Alex Kofman wrote:

It seems you has not applied [Persistent] attribute on your model assembly. Just add such line to AssemblyInfo.cs file:

[assembly: Persistent(AttributeTargetAssemblies = "YourModelNamespace")]

Where "YourModelNamespace" is namespace, where your persistent classes are declared, e.g. in our samples it is "Xtensive.Storage.Samples.Model".

p.s. if you use our project template, this attribute is generated automatically.


Alex Kofman wrote:

Where "YourModelNamespace" is namespace, where your persistent classes are declared, e.g. in our samples it is "Xtensive.Storage.Samples.Model".

I'm sorry... There is a mistake. You should specify your assembly name (without dll suffix), not namespace!

[assembly : Persistent(AttributeTargetAssemblies = "YourAssemblyNameWithoutDllSuffix")]

answered Mar 11 '09 at 04:36

Editor's gravatar image

Editor
46154156157

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA