jessyhoule

Entity Framework / Create Map Code from SQL DB Columns

Dec 25th, 2014
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. select pname + prequire + pmax + ';' from
  2. (
  3. select 'Property(e => e.' + name + ').HasColumnName("'+ name +'")' as pname,
  4. case isnullable
  5.        when 0 then '.IsRequired()'
  6.        else '' end as prequire,
  7. case xtype
  8.        when 167 then '.HasMaxLength(' + CAST(length as varchar(50)) +')'
  9.        else '' end as pmax
  10. from syscolumns where id = 1331807777
  11. ) a
Advertisement
Add Comment
Please, Sign In to add comment