Format:
Recent snippets matching tags of EF4
public class GenderConfiguration : ComplexTypeConfiguration<TypeSex> { public GenereConfiguration() { // set column name with Fluent Api Property(g => g.Value).HasColumnName("Sex"); } }
101 Views
no comments
// enum type public enum Sex { Male=1, Female=2 } // wrapper class for enum support in EF4 public class TypeSex {
203 Views
no comments
public class MyClassConfiguration :EntityTypeConfiguration<MyClass> { public MyClassConfiguration() { //define property key and database generated option, identity in this case, and table generated column order. HasKey(p => p.Uid).Property(c => c.Uid).HasDatabaseGeneratedOption( DatabaseGeneratedOption.Identity).HasColumnOrder(1); // define column type (default navarchar(MAX) last release) and columnlength Property(p => p.Name).HasColumnType("nvarchar(MAX)").HasMaxLength(4000); //Ignore mapping on specific property Ignore(p=>p.Description);
178 Views
no comments
//during context definition, alternatively choose. //Drop and create database strategy DbDatabase.SetInitializer(new DropCreateDatabaseAlways<TestContextEf>()); // Drop and create database if model changes DbDatabase.SetInitializer(new DropCreateDatabaseIfModelChanges<TestContextEF>()); // Create database if not exists DbDatabase.SetInitializer(new CreateDatabaseIfNotExists<TestContextEF>());
90 Views
no comments
DbDatabase.SetInitializer<TestContextEF>(null)
114 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using FooBar.Models; namespace FooBar.Controllers { [HandleError]
120 Views
no comments
' I watched Karl's video about validation with custom rules, and wondered ' why Silverlight, ASP.NET and ASP.NET MVC had DataAnnotations, and ' WPF only had IDataErrorInfo. So I thought of using EF4 as the model, ' and generating a metadata class like in RIA, MVC, etc for WPF and a ' inheritable generic class to convert the validations between IDataErrorInfo ' and the DataAnnotation attributes. ' ' This way validation can happen the same way for each type of client! ' ' Let me know what you think please?
582 Views
no comments
[OperationContract] public Contact SaveContact(Contact entity) { bool _IsDeleted = false; string _EntitySetName; _EntitySetName = "Contacts"; using (CometEntities _Context = new CometEntities()) {
1182 Views
1 comments
'------------------------------------------------------------------------------ ' <auto-generated> ' This code was generated from a template. ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </auto-generated> '------------------------------------------------------------------------------ Option Compare Binary
385 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
