Can somone point me to a tutorial on how to set the meta table. I'm assuming I have to edit the edmx files. I have two EF books and both mention nothing about how to setup default values. I know how to do this using the mssql server but I need to programitically
set this up.
Hi cooper88, you do not edit the sdmx file you create a buddy class see below:
namespace CustomFilters.Models
{
[MetadataTypeAttribute(typeof(Category.CategoryMetadata))]
public partial class Category
{
internal sealed class CategoryMetadata
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public string Description { get; set; }
public byte[] Picture { get; set; }
public EntityCollection<Product> Products { get; set; }
}
}
}
then you add your attribute to the internal seald class (i't internal seald so it is never seen outside of being used for metadata) also noe the properties can be of type Object they do not need to match the actual type.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
cooper88
Member
116 Points
103 Posts
Trying to setup dynamic data
Oct 27, 2011 05:50 AM|LINK
I'm trying to follow scott's blog but I can't find a tutorial on how to setup the meta data.
http://blogs.msdn.com/b/scothu/archive/2010/08/26/automatically-prepopulate-fields-for-insert-in-net-4.aspx
Can somone point me to a tutorial on how to set the meta table. I'm assuming I have to edit the edmx files. I have two EF books and both mention nothing about how to setup default values. I know how to do this using the mssql server but I need to programitically set this up.
DetailsView1.SetMetaTable(DetailsView1.GetMetaTable(), contact);
Thanks.
sjnaughton
All-Star
27318 Points
5458 Posts
MVP
Re: Trying to setup dynamic data
Oct 28, 2011 08:18 AM|LINK
Hi cooper88, you do not edit the sdmx file you create a buddy class see below:
namespace CustomFilters.Models { [MetadataTypeAttribute(typeof(Category.CategoryMetadata))] public partial class Category { internal sealed class CategoryMetadata { public int CategoryID { get; set; } public string CategoryName { get; set; } public string Description { get; set; } public byte[] Picture { get; set; } public EntityCollection<Product> Products { get; set; } } } }then you add your attribute to the internal seald class (i't internal seald so it is never seen outside of being used for metadata) also noe the properties can be of type Object they do not need to match the actual type.
Always seeking an elegant solution.