CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of EF4
C#
public class GenderConfiguration : ComplexTypeConfiguration<TypeSex>
{
   public GenereConfiguration()
    {
      // set column name with Fluent Api
      Property(g => g.Value).HasColumnName("Sex");
    }
}
by pythonyan   April 26, 2011 @ 2:35am
Tags: EF4, CodeFirst
101 Views
no comments
 
C#
// enum type
public enum Sex
{
  Male=1,
  Female=2
}
 
// wrapper class for enum support in EF4
public class TypeSex
{
by pythonyan   April 26, 2011 @ 2:30am
Tags: EF4, CodeFirst
203 Views
no comments
 
C#
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); 
by pythonyan   April 26, 2011 @ 2:14am
Tags: EF4, CodeFirst
178 Views
no comments
 
C#
//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>());
by pythonyan   April 26, 2011 @ 1:57am
Tags: EF4, CodeFirst
90 Views
no comments
 
C#
DbDatabase.SetInitializer<TestContextEF>(null)
by pythonyan   April 26, 2011 @ 1:50am
Tags: EF4, CodeFirst
114 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FooBar.Models;
 
namespace FooBar.Controllers
{
    [HandleError]
by Andrew Hawken   January 10, 2011 @ 12:23pm
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?
by rickrat   July 02, 2010 @ 3:54am
582 Views
no comments
 
C#
[OperationContract]
public Contact SaveContact(Contact entity)
{
    bool _IsDeleted = false;
 
    string _EntitySetName;
    _EntitySetName = "Contacts";
 
    using (CometEntities _Context = new CometEntities())
    {
by Jerry Nixon   June 30, 2010 @ 10:33pm
Tags: EF4, WCF, CRUD
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
by rickrat   June 13, 2010 @ 4:51pm
385 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate