Skip to content

Allow owned entities on a keyless entity type #17890

@aherrick

Description

@aherrick

I have a simple view in my DB that is exposing some fields joined from multiple tables.

I'm able to map my view to my object similar to below:

	public IQueryable<MyDbView> MyDbView => Query<MyDbView>();

        modelBuilder.Query<MyDbView>().ToView(nameof(MyDbView));

MyDbView is an object similar to below.

		public class MyDbView
		{
			public string Name { get; set; }

			public Address OriginAddress { get; set; }
			public Address DestinationAddress { get; set; }
		}

		public class Address
		{ 
                        public int Id { get; set; }
			public string Name { get; set; }

			public string City { get; set; }
			public string State { get; set; }
		}

Since the view has flattened the 2 Address fields into 6 fields (OriginAddressName, OriginAddressCity, etc.), I'd like to inflate them back to the object so MyDbView doesn't have to have a direct mapping to each of the fields and I can reuse my types.

How is the possible?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions