Looking for code examples of Entity Developer Linq to SQL

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
OutOfTouch6947
Posts: 79
Joined: Tue 02 Jun 2015 18:22

Looking for code examples of Entity Developer Linq to SQL

Post by OutOfTouch6947 » Tue 19 Jan 2016 16:48

I am using Entity Developer Pro, the linq to sql template and I am looking for coding examples of using the model at runtime, things like setting the connection string at runtime. loading data saving data, deleting data.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Looking for code examples of Entity Developer Linq to SQL

Post by MariiaI » Wed 20 Jan 2016 14:14

LINQ to SQL model created via Entity Developer is closely similar to standard Microsoft's model (*.dbml model). Thus, the appropriate documentation:
https://msdn.microsoft.com/en-us/librar ... .110).aspx
https://code.msdn.microsoft.com/LINQ-Sa ... s-13a42a54
and some info in the Entity Developer documentation: ORM Support -> LINQ to SQL Models

You can also take a look at LinqConnect documentation and samples, which are available here:
1) http://www.devart.com/linqconnect/docs/?
2) in the Entity Developer documentation: ORM Support -> LinqConnect
3) samples are available in the "C:\Program Files (x86)\Devart\dotConnect\Linq\Samples\" folder after installing LinqConnect (if the Samples component has been selected during installation).

LinqConnect is our own ORM solution, closely compatible to Microsoft LINQ to SQL. LinqConnect includes some features not available in other ORM solutions, e.g. LINQ to SQL. The list of the features is available here:
http://www.devart.com/linqconnect/features.html
http://www.devart.com/linqconnect/linq- ... sions.html

OutOfTouch6947
Posts: 79
Joined: Tue 02 Jun 2015 18:22

Re: Looking for code examples of Entity Developer Linq to SQL

Post by OutOfTouch6947 » Wed 24 Feb 2016 23:14

I am posting to this thread because it is exactly relevant to where I am confused right now.

Ok so I get that you are basically saying just use basic Linq to SQL to write to the database.
In my model I have relationships setup, so I am wondering how would initialize a customer that can have a collection of addresses defined like this:

Code: Select all

 [Association(Name="Customer_CustomerAddress", Storage="_CustomerAddresses", ThisKey="CustomerId", OtherKey="CustomerId", DeleteRule="CASCADE")]
        public EntitySet<CustomerAddress> CustomerAddresses
        {
            get
            {
                return this._CustomerAddresses;
            }
            set
            {
                this._CustomerAddresses.Assign(value);
            }
        }
I am having hard time figuring out how to initialize my model that I generated with EntityDeveloper code first approach to do inserts. CustomerAddresses is a LookUp table in the database that has AddressId CustomerId as FK's but they also make up the tables composite primary key. I guess what I am asking is for examples of using Linq to do inserts with similar classes where the relationships are defined in the model. I get I would new up Address object and Customer Object and InsertOnSubmit(Address) and customer but I don't understand how I am to insert the record into CustomerAddress table if the address id is an identity column.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Looking for code examples of Entity Developer Linq to SQL

Post by MariiaI » Thu 25 Feb 2016 13:10

We are sending you a small test project to the e-mail address you provided in your forum profile. Please check that is not blocked by your mail filter. Please test it and notify us about the results.
If this doesn't help, please describe the issues you are encountering in more details, modify our sample so that the issues can be reproduced and send it back to us, or send us your sample project.

Some useful information:
https://www.devart.com/linqconnect/docs ... lated.html

OutOfTouch6947
Posts: 79
Joined: Tue 02 Jun 2015 18:22

Re: Looking for code examples of Entity Developer Linq to SQL

Post by OutOfTouch6947 » Thu 25 Feb 2016 14:54

This is close but in my code address is a separate table and the the CustomerAddress Table has CustomerID, AddressId as FK's and PK's.
Would this work?

Code: Select all

  CustomerAddress newCustomerAddress1 = new CustomerAddress()
            {
                Customer = newCustomer,
                Address =  newAddress
            };

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Looking for code examples of Entity Developer Linq to SQL

Post by MariiaI » Fri 26 Feb 2016 13:21

We have provided you with a small test project, helpful links and general information regarding working with the standard Microsoft technology - LINQ to SQL.
Unfortunately, your further questions are beyond the scope of our support, we provide support on technical Entity Developer/LinqConnect specific questions.
If you have any questions regarding working with Entity Developer/LinqConnect or encounter any other specific issues, errors with these products, etc., feel free to contact us.

Post Reply