Tables with multiple objects

I did not think that I was crazy, so I returned and made a sample project to reproduce and show what was happening.

I have 4 simple projects, for example below

enter image description here

I am adding EDMX to the data project

enter image description here

Here is my table structure

enter image description here

Here are the properties of EDMX

enter image description here

And the generated class

enter image description here

Add a link to the WCF services library to the data project

enter image description here

Test Wcf Client with Default Tests

enter image description here

Add Wcf Method

enter image description here

And she asks for the EF6 Reference

enter image description here

After adding the link, My method is similar to this

enter image description here

Running the test client again, I get this exception

enter image description here

So, I copy the connection string from the Data.Edmx project and add it to the WCF project

and run the test client and get it returned with the correct table in EDMX.

<T411>

, , . ( ), . . , .

- , ? WCF EF6.1?

enter image description here

enter image description here

enter image description here

,

public partial class Item
{
    public int ItemId { get; set; }
    public string Name { get; set; }
    public int CategoryId { get; set; }

    public virtual Category Category { get; set; }
}

public partial class Category
{
    public Category()
    {
        this.Categories1 = new HashSet<Category>();
        this.Items = new HashSet<Item>();
    }

    public int CategoryId { get; set; }
    public string Name { get; set; }
    public Nullable<int> ParentId { get; set; }

    public virtual ICollection<Category> Categories1 { get; set; }
    public virtual Category Category1 { get; set; }
    public virtual ICollection<Item> Items { get; set; }
}
+4
1

, WCF , ( ).

public virtual Category Category { get; set; }

public virtual ICollection<Category> Categories1 { get; set; }
public virtual Category Category1 { get; set; }
public virtual ICollection<Item> Items { get; set; }

, .

Framework Framework, WCF

+4

Source: https://habr.com/ru/post/1533088/


All Articles