..
This commit is contained in:
@@ -33,5 +33,11 @@ namespace Project
|
||||
public virtual DbSet<EETGW_JobReport_AutoInput> EETGW_JobReport_AutoInput { get; set; }
|
||||
public virtual DbSet<JobReport> JobReport { get; set; }
|
||||
public virtual DbSet<vFindSID> vFindSID { get; set; }
|
||||
public virtual DbSet<Projects> Projects { get; set; }
|
||||
public virtual DbSet<ProjectsHistory> ProjectsHistory { get; set; }
|
||||
public virtual DbSet<ProjectsIOMap> ProjectsIOMap { get; set; }
|
||||
public virtual DbSet<ProjectsMailList> ProjectsMailList { get; set; }
|
||||
public virtual DbSet<ProjectsPart> ProjectsPart { get; set; }
|
||||
public virtual DbSet<Purchase> Purchase { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,179 @@
|
||||
<Property Name="tag" Type="varchar" MaxLength="255" />
|
||||
<Property Name="autoinput" Type="bit" />
|
||||
</EntityType>
|
||||
<EntityType Name="Projects">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="isdel" Type="bit" />
|
||||
<Property Name="category" Type="varchar" MaxLength="50" />
|
||||
<Property Name="status" Type="varchar" MaxLength="50" />
|
||||
<Property Name="asset" Type="varchar" MaxLength="100" />
|
||||
<Property Name="level" Type="int" />
|
||||
<Property Name="rev" Type="int" />
|
||||
<Property Name="process" Type="varchar" MaxLength="50" />
|
||||
<Property Name="part" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="userManager" Type="varchar" MaxLength="50" />
|
||||
<Property Name="usermain" Type="varchar" MaxLength="50" />
|
||||
<Property Name="usersub" Type="varchar" MaxLength="50" />
|
||||
<Property Name="userhw2" Type="varchar" MaxLength="50" />
|
||||
<Property Name="reqstaff" Type="varchar" MaxLength="50" />
|
||||
<Property Name="costo" Type="float" />
|
||||
<Property Name="costn" Type="float" />
|
||||
<Property Name="cnt" Type="int" />
|
||||
<Property Name="remark_req" Type="varchar(max)" />
|
||||
<Property Name="remark_ans" Type="varchar(max)" />
|
||||
<Property Name="sdate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ddate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="odate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="progress" Type="int" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="orderno" Type="varchar" MaxLength="50" />
|
||||
<Property Name="crdue" Type="varchar" MaxLength="10" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="path" Type="varchar" MaxLength="300" />
|
||||
<Property Name="userprocess" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="CMP_Background" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_Description" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_Before" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_After" Type="nvarchar(max)" />
|
||||
<Property Name="bCost" Type="bit" />
|
||||
<Property Name="bFanOut" Type="bit" />
|
||||
<Property Name="div" Type="varchar" MaxLength="2" />
|
||||
<Property Name="EB_Site" Type="varchar" MaxLength="20" />
|
||||
<Property Name="EB_Line" Type="varchar" MaxLength="10" />
|
||||
<Property Name="EB_Team" Type="varchar" MaxLength="10" />
|
||||
<Property Name="EB_Model" Type="varchar" MaxLength="100" />
|
||||
<Property Name="EB_OutSourceName" Type="varchar" MaxLength="100" />
|
||||
<Property Name="EB_RepairTime" Type="float" />
|
||||
<Property Name="EB_ConstNew" Type="float" />
|
||||
<Property Name="EB_BoardName" Type="nvarchar" MaxLength="255" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="div" Type="varchar" MaxLength="10" />
|
||||
<Property Name="remark" Type="varchar(max)" />
|
||||
<Property Name="remark2" Type="varchar(max)" />
|
||||
<Property Name="mailsend" Type="bit" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsIOMap">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="Dir" Type="varchar" MaxLength="20" />
|
||||
<Property Name="PIn" Type="varchar" MaxLength="100" />
|
||||
<Property Name="Description" Type="varchar" MaxLength="100" />
|
||||
<Property Name="Remark" Type="varchar" MaxLength="100" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsMailList">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="enable" Type="bit" />
|
||||
<Property Name="div" Type="varchar" MaxLength="10" />
|
||||
<Property Name="name" Type="varchar" MaxLength="100" />
|
||||
<Property Name="address" Type="varchar" MaxLength="255" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsPart">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="no" Type="int" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="ItemGroup" Type="varchar" MaxLength="100" />
|
||||
<Property Name="ItemModel" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="ItemUnit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ItemName" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="ItemSid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ItemSupply" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="ItemSupplyidx" Type="int" />
|
||||
<Property Name="ItemManu" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="Item" Type="int" />
|
||||
<Property Name="option1" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="option2" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="option3" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="qty" Type="int" />
|
||||
<Property Name="qtyn" Type="int" />
|
||||
<Property Name="price" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amt" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amtn" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="jago" Type="int" />
|
||||
<Property Name="remark" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="qtyjago" Type="varchar" MaxLength="50" />
|
||||
<Property Name="qtybuy" Type="int" />
|
||||
<Property Name="qtyin" Type="int" />
|
||||
<Property Name="bbuy" Type="bit" />
|
||||
<Property Name="bconfirm" Type="bit" />
|
||||
<Property Name="bCancel" Type="bit" />
|
||||
</EntityType>
|
||||
<EntityType Name="Purchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="state" Type="varchar" MaxLength="30" />
|
||||
<Property Name="process" Type="varchar" MaxLength="30" />
|
||||
<Property Name="receive" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sc" Type="varchar" MaxLength="30" />
|
||||
<Property Name="request" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumname" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="pumidx" Type="int" />
|
||||
<Property Name="pumscale" Type="varchar" MaxLength="200" />
|
||||
<Property Name="pumunit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumqty" Type="int" />
|
||||
<Property Name="pumprice" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="varchar" MaxLength="200" />
|
||||
<Property Name="supplyidx" Type="int" />
|
||||
<Property Name="project" Type="varchar(max)" />
|
||||
<Property Name="projectidx" Type="int" />
|
||||
<Property Name="asset" Type="varchar" MaxLength="50" />
|
||||
<Property Name="manuproc" Type="varchar" MaxLength="50" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="indate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="po" Type="varchar" MaxLength="50" />
|
||||
<Property Name="dept" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="bigo" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="isdel" Type="bit" />
|
||||
<Property Name="orderno" Type="varchar" MaxLength="50" />
|
||||
<Property Name="place" Type="varchar" MaxLength="20" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="inqty" Type="int" />
|
||||
</EntityType>
|
||||
<EntityType Name="UserGroup">
|
||||
<Key>
|
||||
<PropertyRef Name="dept" />
|
||||
@@ -178,6 +351,12 @@
|
||||
<EntitySet Name="EETGW_JobReport_AutoInput" EntityType="Self.EETGW_JobReport_AutoInput" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="EETGW_LoginInfo" EntityType="Self.EETGW_LoginInfo" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="JobReport" EntityType="Self.JobReport" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Projects" EntityType="Self.Projects" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsHistory" EntityType="Self.ProjectsHistory" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsIOMap" EntityType="Self.ProjectsIOMap" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsMailList" EntityType="Self.ProjectsMailList" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsPart" EntityType="Self.ProjectsPart" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Purchase" EntityType="Self.Purchase" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="UserGroup" EntityType="Self.UserGroup" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="vFindSID" EntityType="Self.vFindSID" store:Type="Views" store:Schema="dbo">
|
||||
@@ -245,6 +424,12 @@
|
||||
<EntitySet Name="EETGW_JobReport_AutoInput" EntityType="EEModelMain.EETGW_JobReport_AutoInput" />
|
||||
<EntitySet Name="JobReport" EntityType="EEModelMain.JobReport" />
|
||||
<EntitySet Name="vFindSID" EntityType="EEModelMain.vFindSID" />
|
||||
<EntitySet Name="Projects" EntityType="EEModelMain.Projects" />
|
||||
<EntitySet Name="ProjectsHistory" EntityType="EEModelMain.ProjectsHistory" />
|
||||
<EntitySet Name="ProjectsIOMap" EntityType="EEModelMain.ProjectsIOMap" />
|
||||
<EntitySet Name="ProjectsMailList" EntityType="EEModelMain.ProjectsMailList" />
|
||||
<EntitySet Name="ProjectsPart" EntityType="EEModelMain.ProjectsPart" />
|
||||
<EntitySet Name="Purchase" EntityType="EEModelMain.Purchase" />
|
||||
</EntityContainer>
|
||||
<EntityType Name="EETGW_LoginInfo">
|
||||
<Key>
|
||||
@@ -400,6 +585,179 @@
|
||||
<Property Name="price" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="remark" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
</EntityType>
|
||||
<EntityType Name="Projects">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" />
|
||||
<Property Name="gcode" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="isdel" Type="Boolean" />
|
||||
<Property Name="category" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="status" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="asset" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="level" Type="Int32" />
|
||||
<Property Name="rev" Type="Int32" />
|
||||
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="part" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="userManager" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="usermain" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="usersub" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="userhw2" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="reqstaff" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="costo" Type="Double" />
|
||||
<Property Name="costn" Type="Double" />
|
||||
<Property Name="cnt" Type="Int32" />
|
||||
<Property Name="remark_req" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark_ans" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sdate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ddate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="odate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="progress" Type="Int32" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="orderno" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="crdue" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="path" Type="String" MaxLength="300" FixedLength="false" Unicode="false" />
|
||||
<Property Name="userprocess" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Background" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Before" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_After" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="bCost" Type="Boolean" />
|
||||
<Property Name="bFanOut" Type="Boolean" />
|
||||
<Property Name="div" Type="String" MaxLength="2" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Site" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Line" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Team" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Model" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_OutSourceName" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_RepairTime" Type="Double" />
|
||||
<Property Name="EB_ConstNew" Type="Double" />
|
||||
<Property Name="EB_BoardName" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="div" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark2" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="mailsend" Type="Boolean" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsIOMap">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="Dir" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="PIn" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="Description" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="Remark" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsMailList">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="enable" Type="Boolean" />
|
||||
<Property Name="div" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="address" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsPart">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="no" Type="Int32" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="ItemGroup" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemModel" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemUnit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemName" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemSid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemSupply" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemSupplyidx" Type="Int32" />
|
||||
<Property Name="ItemManu" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="Item" Type="Int32" />
|
||||
<Property Name="option1" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="option2" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="option3" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="qty" Type="Int32" />
|
||||
<Property Name="qtyn" Type="Int32" />
|
||||
<Property Name="price" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amt" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amtn" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="jago" Type="Int32" />
|
||||
<Property Name="remark" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="qtyjago" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="qtybuy" Type="Int32" />
|
||||
<Property Name="qtyin" Type="Int32" />
|
||||
<Property Name="bbuy" Type="Boolean" />
|
||||
<Property Name="bconfirm" Type="Boolean" />
|
||||
<Property Name="bCancel" Type="Boolean" />
|
||||
</EntityType>
|
||||
<EntityType Name="Purchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="gcode" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="state" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="process" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="receive" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sc" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="request" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumname" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="pumidx" Type="Int32" />
|
||||
<Property Name="pumscale" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumunit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumqty" Type="Int32" />
|
||||
<Property Name="pumprice" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="supplyidx" Type="Int32" />
|
||||
<Property Name="project" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="projectidx" Type="Int32" />
|
||||
<Property Name="asset" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="manuproc" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="indate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="po" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="dept" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="bigo" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="isdel" Type="Boolean" />
|
||||
<Property Name="orderno" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="place" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="inqty" Type="Int32" />
|
||||
</EntityType>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
@@ -574,6 +932,185 @@
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Projects">
|
||||
<EntityTypeMapping TypeName="EEModelMain.Projects">
|
||||
<MappingFragment StoreEntitySet="Projects">
|
||||
<ScalarProperty Name="EB_BoardName" ColumnName="EB_BoardName" />
|
||||
<ScalarProperty Name="EB_ConstNew" ColumnName="EB_ConstNew" />
|
||||
<ScalarProperty Name="EB_RepairTime" ColumnName="EB_RepairTime" />
|
||||
<ScalarProperty Name="EB_OutSourceName" ColumnName="EB_OutSourceName" />
|
||||
<ScalarProperty Name="EB_Model" ColumnName="EB_Model" />
|
||||
<ScalarProperty Name="EB_Team" ColumnName="EB_Team" />
|
||||
<ScalarProperty Name="EB_Line" ColumnName="EB_Line" />
|
||||
<ScalarProperty Name="EB_Site" ColumnName="EB_Site" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="bFanOut" ColumnName="bFanOut" />
|
||||
<ScalarProperty Name="bCost" ColumnName="bCost" />
|
||||
<ScalarProperty Name="CMP_After" ColumnName="CMP_After" />
|
||||
<ScalarProperty Name="CMP_Before" ColumnName="CMP_Before" />
|
||||
<ScalarProperty Name="CMP_Description" ColumnName="CMP_Description" />
|
||||
<ScalarProperty Name="CMP_Background" ColumnName="CMP_Background" />
|
||||
<ScalarProperty Name="userprocess" ColumnName="userprocess" />
|
||||
<ScalarProperty Name="path" ColumnName="path" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="crdue" ColumnName="crdue" />
|
||||
<ScalarProperty Name="orderno" ColumnName="orderno" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="progress" ColumnName="progress" />
|
||||
<ScalarProperty Name="odate" ColumnName="odate" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="ddate" ColumnName="ddate" />
|
||||
<ScalarProperty Name="sdate" ColumnName="sdate" />
|
||||
<ScalarProperty Name="remark_ans" ColumnName="remark_ans" />
|
||||
<ScalarProperty Name="remark_req" ColumnName="remark_req" />
|
||||
<ScalarProperty Name="cnt" ColumnName="cnt" />
|
||||
<ScalarProperty Name="costn" ColumnName="costn" />
|
||||
<ScalarProperty Name="costo" ColumnName="costo" />
|
||||
<ScalarProperty Name="reqstaff" ColumnName="reqstaff" />
|
||||
<ScalarProperty Name="userhw2" ColumnName="userhw2" />
|
||||
<ScalarProperty Name="usersub" ColumnName="usersub" />
|
||||
<ScalarProperty Name="usermain" ColumnName="usermain" />
|
||||
<ScalarProperty Name="userManager" ColumnName="userManager" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="part" ColumnName="part" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="rev" ColumnName="rev" />
|
||||
<ScalarProperty Name="level" ColumnName="level" />
|
||||
<ScalarProperty Name="asset" ColumnName="asset" />
|
||||
<ScalarProperty Name="status" ColumnName="status" />
|
||||
<ScalarProperty Name="category" ColumnName="category" />
|
||||
<ScalarProperty Name="isdel" ColumnName="isdel" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsHistory">
|
||||
<EntityTypeMapping TypeName="EEModelMain.ProjectsHistory">
|
||||
<MappingFragment StoreEntitySet="ProjectsHistory">
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="mailsend" ColumnName="mailsend" />
|
||||
<ScalarProperty Name="remark2" ColumnName="remark2" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsIOMap">
|
||||
<EntityTypeMapping TypeName="EEModelMain.ProjectsIOMap">
|
||||
<MappingFragment StoreEntitySet="ProjectsIOMap">
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="Remark" ColumnName="Remark" />
|
||||
<ScalarProperty Name="Description" ColumnName="Description" />
|
||||
<ScalarProperty Name="PIn" ColumnName="PIn" />
|
||||
<ScalarProperty Name="Dir" ColumnName="Dir" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsMailList">
|
||||
<EntityTypeMapping TypeName="EEModelMain.ProjectsMailList">
|
||||
<MappingFragment StoreEntitySet="ProjectsMailList">
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="address" ColumnName="address" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="enable" ColumnName="enable" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsPart">
|
||||
<EntityTypeMapping TypeName="EEModelMain.ProjectsPart">
|
||||
<MappingFragment StoreEntitySet="ProjectsPart">
|
||||
<ScalarProperty Name="bCancel" ColumnName="bCancel" />
|
||||
<ScalarProperty Name="bconfirm" ColumnName="bconfirm" />
|
||||
<ScalarProperty Name="bbuy" ColumnName="bbuy" />
|
||||
<ScalarProperty Name="qtyin" ColumnName="qtyin" />
|
||||
<ScalarProperty Name="qtybuy" ColumnName="qtybuy" />
|
||||
<ScalarProperty Name="qtyjago" ColumnName="qtyjago" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="jago" ColumnName="jago" />
|
||||
<ScalarProperty Name="amtn" ColumnName="amtn" />
|
||||
<ScalarProperty Name="amt" ColumnName="amt" />
|
||||
<ScalarProperty Name="price" ColumnName="price" />
|
||||
<ScalarProperty Name="qtyn" ColumnName="qtyn" />
|
||||
<ScalarProperty Name="qty" ColumnName="qty" />
|
||||
<ScalarProperty Name="option3" ColumnName="option3" />
|
||||
<ScalarProperty Name="option2" ColumnName="option2" />
|
||||
<ScalarProperty Name="option1" ColumnName="option1" />
|
||||
<ScalarProperty Name="Item" ColumnName="Item" />
|
||||
<ScalarProperty Name="ItemManu" ColumnName="ItemManu" />
|
||||
<ScalarProperty Name="ItemSupplyidx" ColumnName="ItemSupplyidx" />
|
||||
<ScalarProperty Name="ItemSupply" ColumnName="ItemSupply" />
|
||||
<ScalarProperty Name="ItemSid" ColumnName="ItemSid" />
|
||||
<ScalarProperty Name="ItemName" ColumnName="ItemName" />
|
||||
<ScalarProperty Name="ItemUnit" ColumnName="ItemUnit" />
|
||||
<ScalarProperty Name="ItemModel" ColumnName="ItemModel" />
|
||||
<ScalarProperty Name="ItemGroup" ColumnName="ItemGroup" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="no" ColumnName="no" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Purchase">
|
||||
<EntityTypeMapping TypeName="EEModelMain.Purchase">
|
||||
<MappingFragment StoreEntitySet="Purchase">
|
||||
<ScalarProperty Name="inqty" ColumnName="inqty" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="place" ColumnName="place" />
|
||||
<ScalarProperty Name="orderno" ColumnName="orderno" />
|
||||
<ScalarProperty Name="isdel" ColumnName="isdel" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="bigo" ColumnName="bigo" />
|
||||
<ScalarProperty Name="dept" ColumnName="dept" />
|
||||
<ScalarProperty Name="po" ColumnName="po" />
|
||||
<ScalarProperty Name="indate" ColumnName="indate" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="manuproc" ColumnName="manuproc" />
|
||||
<ScalarProperty Name="asset" ColumnName="asset" />
|
||||
<ScalarProperty Name="projectidx" ColumnName="projectidx" />
|
||||
<ScalarProperty Name="project" ColumnName="project" />
|
||||
<ScalarProperty Name="supplyidx" ColumnName="supplyidx" />
|
||||
<ScalarProperty Name="supply" ColumnName="supply" />
|
||||
<ScalarProperty Name="pumamt" ColumnName="pumamt" />
|
||||
<ScalarProperty Name="pumprice" ColumnName="pumprice" />
|
||||
<ScalarProperty Name="pumqty" ColumnName="pumqty" />
|
||||
<ScalarProperty Name="pumunit" ColumnName="pumunit" />
|
||||
<ScalarProperty Name="pumscale" ColumnName="pumscale" />
|
||||
<ScalarProperty Name="pumidx" ColumnName="pumidx" />
|
||||
<ScalarProperty Name="pumname" ColumnName="pumname" />
|
||||
<ScalarProperty Name="sid" ColumnName="sid" />
|
||||
<ScalarProperty Name="request" ColumnName="request" />
|
||||
<ScalarProperty Name="sc" ColumnName="sc" />
|
||||
<ScalarProperty Name="receive" ColumnName="receive" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="state" ColumnName="state" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
<EntityTypeShape EntityType="EEModelMain.EETGW_JobReport_AutoInput" Width="1.5" PointX="0.75" PointY="4.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.JobReport" Width="1.5" PointX="5.375" PointY="3.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.vFindSID" Width="1.5" PointX="7.375" PointY="6.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.Projects" Width="1.5" PointX="3.75" PointY="9.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.ProjectsHistory" Width="1.5" PointX="9.75" PointY="6.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.ProjectsIOMap" Width="1.5" PointX="9.75" PointY="10.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.ProjectsMailList" Width="1.5" PointX="0.75" PointY="11.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.ProjectsPart" Width="1.5" PointX="11.75" PointY="3.75" />
|
||||
<EntityTypeShape EntityType="EEModelMain.Purchase" Width="1.5" PointX="5.75" PointY="11.75" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
|
||||
199
Project/Controller/CustomerController.cs
Normal file
199
Project/Controller/CustomerController.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public class CustomerController : BaseController
|
||||
{
|
||||
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Test()
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Find()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesCommon();
|
||||
var rows = db.Customs.Where(t => t.gcode == FCOMMON.info.Login.gcode).OrderBy(t => t.name);
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.name}</th>");
|
||||
tbody.AppendLine($"<td>{item.name2}</td>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
//tbody.AppendLine($"<td>{item.model}</td>");
|
||||
|
||||
//if (item.price == null)
|
||||
// tbody.AppendLine($"<td>--</td>");
|
||||
//else
|
||||
//{
|
||||
// var price = (double)item.price / 1000.0;
|
||||
|
||||
// tbody.AppendLine($"<td>{price.ToString("N0")}</td>");
|
||||
//}
|
||||
|
||||
|
||||
//tbody.AppendLine($"<td>{item.manu}</td>");
|
||||
//tbody.AppendLine($"<td>{item.supply}</td>");
|
||||
|
||||
//if (item.remark.Length > 10)
|
||||
// tbody.AppendLine($"<td>{item.remark.Substring(0, 10)}...</td>");
|
||||
//else
|
||||
// tbody.AppendLine($"<td>{item.remark}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
//if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesCommon();
|
||||
var sd = DateTime.Now.ToString("yyyy-MM-01");
|
||||
var rows = db.Customs.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode).OrderBy(t=>t.name);
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.grp}</th>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
tbody.AppendLine($"<td>{item.name2}</td>");
|
||||
tbody.AppendLine($"<td>{item.tel}</td>");
|
||||
tbody.AppendLine($"<td>{item.fax}</td>");
|
||||
tbody.AppendLine($"<td>{item.email}</td>");
|
||||
tbody.AppendLine($"<td>{item.address}</td>");
|
||||
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty( item.memo)==false && item.memo.Length > 10) tbody.AppendLine($"<td>{item.memo.Substring(0, 10)}...</td>");
|
||||
else tbody.AppendLine($"<td>{item.memo}</td>");
|
||||
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
198
Project/Controller/JobreportController.cs
Normal file
198
Project/Controller/JobreportController.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public class JobreportController : BaseController
|
||||
{
|
||||
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Test()
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Find()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesJobreport();
|
||||
var sd = DateTime.Now.ToShortDateString();
|
||||
var rows = db.vJobReportForUser.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.pdate.CompareTo(sd) == 0).OrderBy(t => t.name);
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.pdate}</th>");
|
||||
tbody.AppendLine($"<td>{item.status}</td>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
tbody.AppendLine($"<td>{item.projectName}</td>");
|
||||
tbody.AppendLine($"<td>{item.hrs}</td>");
|
||||
tbody.AppendLine($"<td>{item.ot}</td>");
|
||||
tbody.AppendLine($"<td>{item.description}</td>");
|
||||
|
||||
|
||||
if (item.description.Length > 10)
|
||||
tbody.AppendLine($"<td>{item.description.Substring(0, 10)}...</td>");
|
||||
else
|
||||
tbody.AppendLine($"<td>{item.description}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
//if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesJobreport();
|
||||
var sd = DateTime.Now.ToString("yyyy-MM-01");
|
||||
var ed = DateTime.Now.ToShortDateString();
|
||||
var rows = db.vJobReportForUser.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode && t.id == FCOMMON.info.Login.no && t.pdate.CompareTo(sd) >= 0 && t.pdate.CompareTo(ed) <= 1).OrderByDescending(t => t.pdate);
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
|
||||
tbody.AppendLine($"<th scope='row'>{item.pdate.Substring(5)}</th>");
|
||||
tbody.AppendLine($"<td>{item.ww}</td>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
|
||||
if (item.status == "진행 중" || item.status.EndsWith("%"))
|
||||
tbody.AppendLine($"<td class='table-info text-center'>{item.status}</td>");
|
||||
else
|
||||
tbody.AppendLine($"<td class='text-center'>{item.status}</td>");
|
||||
|
||||
tbody.AppendLine($"<td>{item.type}</td>");
|
||||
tbody.AppendLine($"<td>{item.projectName}</td>");
|
||||
tbody.AppendLine($"<td>{item.hrs}</td>");
|
||||
tbody.AppendLine($"<td>{item.ot}</td>");
|
||||
|
||||
tbody.AppendLine("<td><span class='d-inline-block text-truncate' style='max-width: 150px;'>");
|
||||
tbody.AppendLine(item.description);
|
||||
tbody.AppendLine("</span></td>");
|
||||
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
200
Project/Controller/ProjectController.cs
Normal file
200
Project/Controller/ProjectController.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public class ProjectController : BaseController
|
||||
{
|
||||
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Test()
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Find()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesProject();
|
||||
|
||||
|
||||
var rows = db.Projects.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.status.Contains("완료") == false).OrderByDescending(t => t.pdate).Take(50);
|
||||
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.pdate}</th>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
|
||||
|
||||
//if (item.description.Length > 10)
|
||||
// tbody.AppendLine($"<td>{item.description.Substring(0, 10)}...</td>");
|
||||
//else
|
||||
// tbody.AppendLine($"<td>{item.description}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
//if (searchkey.isEmpty() == false)
|
||||
{
|
||||
|
||||
var db = new EEEntitiesProject();
|
||||
|
||||
|
||||
var rows = db.Projects.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.status.Contains("완료") == false).OrderByDescending(t => t.pdate).Take(50);
|
||||
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.idx}</th>");
|
||||
tbody.AppendLine($"<td>{item.status}</td>");
|
||||
tbody.AppendLine($"<td>{item.progress}</td>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
tbody.AppendLine($"<td>{item.reqstaff}</td>");
|
||||
tbody.AppendLine($"<td>{item.userManager}</td>");
|
||||
tbody.AppendLine($"<td>{item.cnt}</td>");
|
||||
tbody.AppendLine($"<td>{item.costo}</td>");
|
||||
tbody.AppendLine($"<td>{item.costn}</td>");
|
||||
tbody.AppendLine($"<td>{item.costo - item.costn}</td>");
|
||||
tbody.AppendLine($"<td>{item.orderno}</td>");
|
||||
if (item.memo != null)
|
||||
tbody.AppendLine($"<td>{item.memo}</td>");
|
||||
else
|
||||
tbody.AppendLine($"<td> </td>");
|
||||
|
||||
|
||||
|
||||
//if (item.description.Length > 10)
|
||||
// tbody.AppendLine($"<td>{item.description.Substring(0, 10)}...</td>");
|
||||
//else
|
||||
// tbody.AppendLine($"<td>{item.description}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
208
Project/Controller/PurchaseController.cs
Normal file
208
Project/Controller/PurchaseController.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public class PurchaseController : BaseController
|
||||
{
|
||||
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Test()
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Find()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesMain();
|
||||
var rows = db.vFindSID.Where(t => t.sid.Contains(searchkey) || t.name.Contains(searchkey) || t.manu.Contains(searchkey) || t.model.Contains(searchkey));
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.Location}</th>");
|
||||
tbody.AppendLine($"<td>{item.sid}</td>");
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
tbody.AppendLine($"<td>{item.model}</td>");
|
||||
|
||||
if (item.price == null)
|
||||
tbody.AppendLine($"<td>--</td>");
|
||||
else
|
||||
{
|
||||
var price = (double)item.price / 1000.0;
|
||||
|
||||
tbody.AppendLine($"<td>{price.ToString("N0")}</td>");
|
||||
}
|
||||
|
||||
|
||||
tbody.AppendLine($"<td>{item.manu}</td>");
|
||||
tbody.AppendLine($"<td>{item.supply}</td>");
|
||||
|
||||
if (item.remark.Length > 10)
|
||||
tbody.AppendLine($"<td>{item.remark.Substring(0, 10)}...</td>");
|
||||
else
|
||||
tbody.AppendLine($"<td>{item.remark}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
//로그인이 되어있지않다면 로그인을 가져온다
|
||||
MethodResult result;
|
||||
result = View();
|
||||
|
||||
|
||||
var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
|
||||
var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
|
||||
var model = GetGlobalModel();
|
||||
var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
|
||||
|
||||
//기본값을 찾아서 없애줘야한다
|
||||
var searchkey = string.Empty;
|
||||
if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
|
||||
|
||||
var tbody = new System.Text.StringBuilder();
|
||||
|
||||
//테이블데이터생성
|
||||
var itemcnt = 0;
|
||||
//if (searchkey.isEmpty() == false)
|
||||
{
|
||||
var db = new EEEntitiesPurchase();
|
||||
var sd = DateTime.Now.ToString("yyyy-MM-01");
|
||||
var rows = db.vPurchase.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode && t.pdate.CompareTo(sd) >= 0).OrderByDescending(t => t.pdate);
|
||||
itemcnt = rows.Count();
|
||||
foreach (var item in rows)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine($"<th scope='row'>{item.pdate.Substring(5)}</th>");
|
||||
|
||||
if (item.state == "---") tbody.AppendLine($"<td class='table-info'>{item.state}</td>");
|
||||
else if (item.state == "Received") tbody.AppendLine($"<td class='table-success'>{item.state}</td>");
|
||||
else tbody.AppendLine($"<td>{item.state}</td>");
|
||||
|
||||
tbody.AppendLine($"<td>{item.name}</td>");
|
||||
tbody.AppendLine($"<td>{item.sid}</td>");
|
||||
tbody.AppendLine($"<td>{item.pumname}</td>");
|
||||
|
||||
if (item.pumscale.Length > 10) tbody.AppendLine($"<td>{item.pumscale.Substring(0, 10)}...</td>");
|
||||
else tbody.AppendLine($"<td>{item.pumscale}</td>");
|
||||
|
||||
tbody.AppendLine($"<td>{item.pumqty}</td>");
|
||||
tbody.AppendLine($"<td>{item.pumprice}</td>");
|
||||
tbody.AppendLine($"<td>{item.pumamt}</td>");
|
||||
tbody.AppendLine($"<td>{item.supply}</td>");
|
||||
if (item.project.Length > 10) tbody.AppendLine($"<td>{item.project.Substring(0, 10)}...</td>");
|
||||
else tbody.AppendLine($"<td>{item.project}</td>");
|
||||
|
||||
if (item.bigo.Length > 10) tbody.AppendLine($"<td>{item.bigo.Substring(0, 10)}...</td>");
|
||||
else tbody.AppendLine($"<td>{item.bigo}</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//아잍쳄이 없는경우
|
||||
if (itemcnt == 0)
|
||||
{
|
||||
tbody.AppendLine("<tr>");
|
||||
tbody.AppendLine("<th scope='row'>1</th>");
|
||||
tbody.AppendLine("<td colspan='6'>자료가 없습니다</td>");
|
||||
tbody.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
|
||||
var contents = result.Content.Replace("{search}", searchkey);
|
||||
contents = contents.Replace("{tabledata}", tbody.ToString());
|
||||
contents = contents.Replace("{cnt}", itemcnt.ToString());
|
||||
|
||||
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
//최종문자 적용
|
||||
result.Content = contents;
|
||||
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
result.Content,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
35
Project/Customs.cs
Normal file
35
Project/Customs.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Customs
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public string grp { get; set; }
|
||||
public string uptae { get; set; }
|
||||
public string name { get; set; }
|
||||
public string name2 { get; set; }
|
||||
public string owner { get; set; }
|
||||
public string ownertel { get; set; }
|
||||
public string address { get; set; }
|
||||
public string tel { get; set; }
|
||||
public string fax { get; set; }
|
||||
public string email { get; set; }
|
||||
public string memo { get; set; }
|
||||
public string staff { get; set; }
|
||||
public string stafftel { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -229,12 +229,19 @@
|
||||
<DependentUpon>AdoNetEFMain.edmx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BaseController.cs" />
|
||||
<Compile Include="Controller\ProjectController.cs" />
|
||||
<Compile Include="Controller\JobreportController.cs" />
|
||||
<Compile Include="Controller\CustomerController.cs" />
|
||||
<Compile Include="Controller\PurchaseController.cs" />
|
||||
<Compile Include="Controller\ItemController.cs" />
|
||||
<Compile Include="Controller\HomeController.cs" />
|
||||
<Compile Include="Controller\ResourceController.cs" />
|
||||
<Compile Include="Controller\ResultController.cs" />
|
||||
<Compile Include="Controller\SettingController.cs" />
|
||||
<Compile Include="CResult.cs" />
|
||||
<Compile Include="Customs.cs">
|
||||
<DependentUpon>ModelCommon.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DataSet1.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -334,6 +341,15 @@
|
||||
<Compile Include="EETGW_LoginInfo.cs">
|
||||
<DependentUpon>AdoNetEFMain.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EETGW_ProjecthistoryD.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EETGW_ProjectsSchedule.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EETGW_ProjectToDo.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="fLog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -352,8 +368,11 @@
|
||||
<Compile Include="fSetting.Designer.cs">
|
||||
<DependentUpon>fSetting.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Items.cs">
|
||||
<DependentUpon>ModelPurchase.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="JobReport.cs">
|
||||
<DependentUpon>AdoNetEFMain.tt</DependentUpon>
|
||||
<DependentUpon>ModelJobreport.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Language\Lang.cs" />
|
||||
<Compile Include="Manager\DataBaseManager.cs" />
|
||||
@@ -361,10 +380,88 @@
|
||||
<Compile Include="Manager\ModelManager.cs" />
|
||||
<Compile Include="MessageWindow.cs" />
|
||||
<Compile Include="MethodExtentions.cs" />
|
||||
<Compile Include="ModelCommon.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelCommon.Context.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelCommon.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelCommon.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelCommon.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelCommon.edmx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelJobreport.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelJobreport.Context.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelJobreport.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelJobreport.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelJobreport.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelJobreport.edmx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelProject.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelProject.Context.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelProject.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelProject.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelProject.edmx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelPurchase.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelPurchase.Context.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelPurchase.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelPurchase.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModelPurchase.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ModelPurchase.edmx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\PageModel.cs" />
|
||||
<Compile Include="OWIN\Startup.cs" />
|
||||
<Compile Include="OWIN\StartupSSE.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Projects.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectsHistory.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectsIOMap.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectsMailList.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectsPart.cs">
|
||||
<DependentUpon>ModelProject.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Purchase.cs">
|
||||
<DependentUpon>ModelPurchase.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="SqlServerTypes\Loader.cs" />
|
||||
<Compile Include="UserGroup.cs">
|
||||
@@ -379,6 +476,12 @@
|
||||
<Compile Include="vGroupUser.cs">
|
||||
<DependentUpon>AdoNetEFMain.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="vJobReportForUser.cs">
|
||||
<DependentUpon>ModelJobreport.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="vPurchase.cs">
|
||||
<DependentUpon>ModelPurchase.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="_Common\fADSUserList.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -569,6 +672,34 @@
|
||||
<None Include="Manual.pdf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<EntityDeploy Include="ModelPurchase.edmx">
|
||||
<Generator>EntityModelCodeGenerator</Generator>
|
||||
<LastGenOutput>ModelPurchase.Designer.cs</LastGenOutput>
|
||||
</EntityDeploy>
|
||||
<EntityDeploy Include="ModelCommon.edmx">
|
||||
<Generator>EntityModelCodeGenerator</Generator>
|
||||
<LastGenOutput>ModelCommon.Designer.cs</LastGenOutput>
|
||||
</EntityDeploy>
|
||||
<None Include="ModelCommon.edmx.diagram">
|
||||
<DependentUpon>ModelCommon.edmx</DependentUpon>
|
||||
</None>
|
||||
<EntityDeploy Include="ModelJobreport.edmx">
|
||||
<Generator>EntityModelCodeGenerator</Generator>
|
||||
<LastGenOutput>ModelJobreport.Designer.cs</LastGenOutput>
|
||||
</EntityDeploy>
|
||||
<None Include="ModelJobreport.edmx.diagram">
|
||||
<DependentUpon>ModelJobreport.edmx</DependentUpon>
|
||||
</None>
|
||||
<EntityDeploy Include="ModelProject.edmx">
|
||||
<Generator>EntityModelCodeGenerator</Generator>
|
||||
<LastGenOutput>ModelProject.Designer.cs</LastGenOutput>
|
||||
</EntityDeploy>
|
||||
<None Include="ModelProject.edmx.diagram">
|
||||
<DependentUpon>ModelProject.edmx</DependentUpon>
|
||||
</None>
|
||||
<None Include="ModelPurchase.edmx.diagram">
|
||||
<DependentUpon>ModelPurchase.edmx</DependentUpon>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
@@ -603,6 +734,46 @@
|
||||
<Content Include="libxl.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ModelCommon.Context.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelCommon.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelCommon.Context.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelCommon.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelCommon.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelCommon.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelJobreport.Context.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelJobreport.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelJobreport.Context.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelJobreport.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelJobreport.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelJobreport.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelProject.Context.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelProject.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelProject.Context.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelProject.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelProject.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelProject.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelPurchase.Context.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelPurchase.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelPurchase.Context.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="ModelPurchase.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<DependentUpon>ModelPurchase.edmx</DependentUpon>
|
||||
<LastGenOutput>ModelPurchase.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="SqlServerTypes\readme.htm" />
|
||||
<Content Include="SqlServerTypes\x64\msvcr120.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
33
Project/EETGW_ProjectToDo.cs
Normal file
33
Project/EETGW_ProjectToDo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class EETGW_ProjectToDo
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public int pidx { get; set; }
|
||||
public Nullable<int> pseq { get; set; }
|
||||
public Nullable<int> sw { get; set; }
|
||||
public Nullable<int> ww { get; set; }
|
||||
public string sort { get; set; }
|
||||
public string cate { get; set; }
|
||||
public string title { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string edate { get; set; }
|
||||
public Nullable<int> process { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string remark2 { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
27
Project/EETGW_ProjecthistoryD.cs
Normal file
27
Project/EETGW_ProjecthistoryD.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class EETGW_ProjecthistoryD
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public int pidx { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string div { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string remark2 { get; set; }
|
||||
public Nullable<bool> mailsend { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
32
Project/EETGW_ProjectsSchedule.cs
Normal file
32
Project/EETGW_ProjectsSchedule.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class EETGW_ProjectsSchedule
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public Nullable<int> project { get; set; }
|
||||
public Nullable<int> seq { get; set; }
|
||||
public string title { get; set; }
|
||||
public Nullable<int> sw { get; set; }
|
||||
public Nullable<int> ew { get; set; }
|
||||
public Nullable<int> swa { get; set; }
|
||||
public Nullable<int> ewa { get; set; }
|
||||
public string uid { get; set; }
|
||||
public string memo { get; set; }
|
||||
public Nullable<int> progress { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
40
Project/Items.cs
Normal file
40
Project/Items.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Items
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public Nullable<bool> disable { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public string cate { get; set; }
|
||||
public string name { get; set; }
|
||||
public string sid { get; set; }
|
||||
public string model { get; set; }
|
||||
public string manu { get; set; }
|
||||
public Nullable<double> scale { get; set; }
|
||||
public string unit { get; set; }
|
||||
public string supply { get; set; }
|
||||
public Nullable<int> supplyidx { get; set; }
|
||||
public Nullable<decimal> price { get; set; }
|
||||
public string memo { get; set; }
|
||||
public byte[] image { get; set; }
|
||||
public Nullable<bool> bparam1 { get; set; }
|
||||
public Nullable<int> iparam1 { get; set; }
|
||||
public string import { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
public Nullable<bool> bEstimate { get; set; }
|
||||
public Nullable<bool> bSAP { get; set; }
|
||||
}
|
||||
}
|
||||
30
Project/ModelCommon.Context.cs
Normal file
30
Project/ModelCommon.Context.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class EEEntitiesCommon : DbContext
|
||||
{
|
||||
public EEEntitiesCommon()
|
||||
: base("name=EEEntitiesCommon")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
public virtual DbSet<Customs> Customs { get; set; }
|
||||
}
|
||||
}
|
||||
636
Project/ModelCommon.Context.tt
Normal file
636
Project/ModelCommon.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelCommon.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||
if (container == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
<#
|
||||
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
}
|
||||
|
||||
#>
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
<#
|
||||
if (container.FunctionImports.Any())
|
||||
{
|
||||
#>
|
||||
using System.Data.Entity.Core.Objects;
|
||||
using System.Linq;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||
{
|
||||
public <#=code.Escape(container)#>()
|
||||
: base("name=<#=container.Name#>")
|
||||
{
|
||||
<#
|
||||
if (!loader.IsLazyLoadingEnabled(container))
|
||||
{
|
||||
#>
|
||||
this.Configuration.LazyLoadingEnabled = false;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
// Note: the DbSet members are defined below such that the getter and
|
||||
// setter always have the same accessibility as the DbSet definition
|
||||
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
<#
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var edmFunction in container.FunctionImports)
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
|
||||
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
if (typeMapper.IsComposable(edmFunction))
|
||||
{
|
||||
#>
|
||||
|
||||
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
|
||||
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
}
|
||||
<#+
|
||||
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||
{
|
||||
#>
|
||||
var <#=name#> = <#=isNotNull#> ?
|
||||
<#=notNullInit#> :
|
||||
<#=nullInit#>;
|
||||
|
||||
<#+
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string DbSetInitializer(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} = Set<{1}>();",
|
||||
_code.Escape(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
10
Project/ModelCommon.Designer.cs
generated
Normal file
10
Project/ModelCommon.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\Project\ModelCommon.edmx'에 대해 T4 코드 생성이 사용됩니다.
|
||||
// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을
|
||||
// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때
|
||||
// 속성 창에서 사용할 수 있습니다.
|
||||
|
||||
// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만
|
||||
// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및
|
||||
// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한
|
||||
// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를
|
||||
// 선택하십시오.
|
||||
9
Project/ModelCommon.cs
Normal file
9
Project/ModelCommon.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
115
Project/ModelCommon.edmx
Normal file
115
Project/ModelCommon.edmx
Normal file
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="EEModelCommon.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="Customs">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="grp" Type="varchar" MaxLength="20" />
|
||||
<Property Name="uptae" Type="varchar" MaxLength="100" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="name2" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="owner" Type="nvarchar" MaxLength="50" />
|
||||
<Property Name="ownertel" Type="nvarchar" MaxLength="50" />
|
||||
<Property Name="address" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="tel" Type="varchar" MaxLength="150" />
|
||||
<Property Name="fax" Type="varchar" MaxLength="100" />
|
||||
<Property Name="email" Type="varchar" MaxLength="100" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="staff" Type="nvarchar" MaxLength="250" />
|
||||
<Property Name="stafftel" Type="varchar" MaxLength="150" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEModelCommonStoreContainer">
|
||||
<EntitySet Name="Customs" EntityType="Self.Customs" Schema="dbo" store:Type="Tables" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="EEModelCommon" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
<EntityType Name="Customs">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="grp" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="uptae" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="name2" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="owner" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ownertel" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
<Property Name="address" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="tel" Type="String" MaxLength="150" FixedLength="false" Unicode="false" />
|
||||
<Property Name="fax" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="email" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="staff" Type="String" MaxLength="250" FixedLength="false" Unicode="true" />
|
||||
<Property Name="stafftel" Type="String" MaxLength="150" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEEntitiesCommon" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="Customs" EntityType="Self.Customs" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||
<EntityContainerMapping StorageEntityContainer="EEModelCommonStoreContainer" CdmEntityContainer="EEEntitiesCommon">
|
||||
<EntitySetMapping Name="Customs">
|
||||
<EntityTypeMapping TypeName="EEModelCommon.Customs">
|
||||
<MappingFragment StoreEntitySet="Customs">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="grp" ColumnName="grp" />
|
||||
<ScalarProperty Name="uptae" ColumnName="uptae" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="name2" ColumnName="name2" />
|
||||
<ScalarProperty Name="owner" ColumnName="owner" />
|
||||
<ScalarProperty Name="ownertel" ColumnName="ownertel" />
|
||||
<ScalarProperty Name="address" ColumnName="address" />
|
||||
<ScalarProperty Name="tel" ColumnName="tel" />
|
||||
<ScalarProperty Name="fax" ColumnName="fax" />
|
||||
<ScalarProperty Name="email" ColumnName="email" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="staff" ColumnName="staff" />
|
||||
<ScalarProperty Name="stafftel" ColumnName="stafftel" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Connection>
|
||||
<Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="false" />
|
||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||
<DesignerProperty Name="CodeGenerationStrategy" Value="없음" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<Diagrams></Diagrams>
|
||||
</Designer>
|
||||
</edmx:Edmx>
|
||||
12
Project/ModelCommon.edmx.diagram
Normal file
12
Project/ModelCommon.edmx.diagram
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram DiagramId="a73304291c754683aebd32c8be38c3a9" Name="Diagram1">
|
||||
<EntityTypeShape EntityType="EEModelCommon.Customs" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
||||
733
Project/ModelCommon.tt
Normal file
733
Project/ModelCommon.tt
Normal file
@@ -0,0 +1,733 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelCommon.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
WriteHeader(codeStringGenerator, fileManager);
|
||||
|
||||
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(entity.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||
{
|
||||
<#
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public <#=code.Escape(entity)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var navigationProperty in collectionNavigationProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach (var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(complexProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||
if (navigationProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach (var navigationProperty in navigationProperties)
|
||||
{
|
||||
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(complex.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||
{
|
||||
<#
|
||||
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
public <#=code.Escape(complex)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach(var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var edmProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#
|
||||
if (typeMapper.EnumIsFlags(enumType))
|
||||
{
|
||||
#>
|
||||
[Flags]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||
{
|
||||
<#
|
||||
var foundOne = false;
|
||||
|
||||
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||
{
|
||||
foundOne = true;
|
||||
#>
|
||||
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||
<#
|
||||
}
|
||||
|
||||
if (foundOne)
|
||||
{
|
||||
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
fileManager.Process();
|
||||
|
||||
#>
|
||||
<#+
|
||||
|
||||
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||
{
|
||||
fileManager.StartHeader();
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||
<#+
|
||||
fileManager.EndBlock();
|
||||
}
|
||||
|
||||
public void BeginNamespace(CodeGenerationTools code)
|
||||
{
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#+
|
||||
PushIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndNamespace(CodeGenerationTools code)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
31
Project/ModelJobreport.Context.cs
Normal file
31
Project/ModelJobreport.Context.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class EEEntitiesJobreport : DbContext
|
||||
{
|
||||
public EEEntitiesJobreport()
|
||||
: base("name=EEEntitiesJobreport")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
public virtual DbSet<JobReport> JobReport { get; set; }
|
||||
public virtual DbSet<vJobReportForUser> vJobReportForUser { get; set; }
|
||||
}
|
||||
}
|
||||
636
Project/ModelJobreport.Context.tt
Normal file
636
Project/ModelJobreport.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelJobreport.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||
if (container == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
<#
|
||||
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
}
|
||||
|
||||
#>
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
<#
|
||||
if (container.FunctionImports.Any())
|
||||
{
|
||||
#>
|
||||
using System.Data.Entity.Core.Objects;
|
||||
using System.Linq;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||
{
|
||||
public <#=code.Escape(container)#>()
|
||||
: base("name=<#=container.Name#>")
|
||||
{
|
||||
<#
|
||||
if (!loader.IsLazyLoadingEnabled(container))
|
||||
{
|
||||
#>
|
||||
this.Configuration.LazyLoadingEnabled = false;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
// Note: the DbSet members are defined below such that the getter and
|
||||
// setter always have the same accessibility as the DbSet definition
|
||||
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
<#
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var edmFunction in container.FunctionImports)
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
|
||||
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
if (typeMapper.IsComposable(edmFunction))
|
||||
{
|
||||
#>
|
||||
|
||||
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
|
||||
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
}
|
||||
<#+
|
||||
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||
{
|
||||
#>
|
||||
var <#=name#> = <#=isNotNull#> ?
|
||||
<#=notNullInit#> :
|
||||
<#=nullInit#>;
|
||||
|
||||
<#+
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string DbSetInitializer(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} = Set<{1}>();",
|
||||
_code.Escape(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
10
Project/ModelJobreport.Designer.cs
generated
Normal file
10
Project/ModelJobreport.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\Project\ModelJobreport.edmx'에 대해 T4 코드 생성이 사용됩니다.
|
||||
// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을
|
||||
// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때
|
||||
// 속성 창에서 사용할 수 있습니다.
|
||||
|
||||
// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만
|
||||
// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및
|
||||
// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한
|
||||
// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를
|
||||
// 선택하십시오.
|
||||
9
Project/ModelJobreport.cs
Normal file
9
Project/ModelJobreport.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
220
Project/ModelJobreport.edmx
Normal file
220
Project/ModelJobreport.edmx
Normal file
@@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="EEModelJobreport.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="JobReport">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="pidx" Type="int" />
|
||||
<Property Name="projectName" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="uid" Type="varchar" MaxLength="20" />
|
||||
<Property Name="requestpart" Type="varchar" MaxLength="50" />
|
||||
<Property Name="package" Type="varchar" MaxLength="50" />
|
||||
<Property Name="status" Type="varchar" MaxLength="20" />
|
||||
<Property Name="type" Type="varchar" MaxLength="50" />
|
||||
<Property Name="process" Type="varchar" MaxLength="50" />
|
||||
<Property Name="description" Type="nvarchar(max)" />
|
||||
<Property Name="remark" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="hrs" Type="float" />
|
||||
<Property Name="ot" Type="float" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="description2" Type="nvarchar(max)" />
|
||||
<Property Name="tag" Type="varchar" MaxLength="255" />
|
||||
<Property Name="autoinput" Type="bit" />
|
||||
</EntityType>
|
||||
<!--생성 중 오류 발생:
|
||||
경고 6002: 테이블/뷰 'EE.dbo.vJobReportForUser'에 기본 키가 정의되지 않았습니다. 키가 유추되었고 읽기 전용 테이블/뷰로 정의되었습니다.-->
|
||||
<EntityType Name="vJobReportForUser">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
<PropertyRef Name="gcode" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="id" Type="varchar" MaxLength="20" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="process" Type="varchar" MaxLength="50" />
|
||||
<Property Name="type" Type="varchar" MaxLength="50" />
|
||||
<Property Name="svalue" Type="varchar" MaxLength="255" />
|
||||
<Property Name="hrs" Type="float" />
|
||||
<Property Name="ot" Type="float" />
|
||||
<Property Name="requestpart" Type="varchar" MaxLength="50" />
|
||||
<Property Name="package" Type="varchar" MaxLength="50" />
|
||||
<Property Name="userProcess" Type="varchar" MaxLength="50" />
|
||||
<Property Name="status" Type="varchar" MaxLength="20" />
|
||||
<Property Name="projectName" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="description" Type="nvarchar(max)" />
|
||||
<Property Name="ww" Type="varchar" MaxLength="6" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEModelJobreportStoreContainer">
|
||||
<EntitySet Name="JobReport" EntityType="Self.JobReport" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="vJobReportForUser" EntityType="Self.vJobReportForUser" store:Type="Views" store:Schema="dbo">
|
||||
<DefiningQuery>SELECT
|
||||
[vJobReportForUser].[idx] AS [idx],
|
||||
[vJobReportForUser].[pdate] AS [pdate],
|
||||
[vJobReportForUser].[gcode] AS [gcode],
|
||||
[vJobReportForUser].[id] AS [id],
|
||||
[vJobReportForUser].[name] AS [name],
|
||||
[vJobReportForUser].[process] AS [process],
|
||||
[vJobReportForUser].[type] AS [type],
|
||||
[vJobReportForUser].[svalue] AS [svalue],
|
||||
[vJobReportForUser].[hrs] AS [hrs],
|
||||
[vJobReportForUser].[ot] AS [ot],
|
||||
[vJobReportForUser].[requestpart] AS [requestpart],
|
||||
[vJobReportForUser].[package] AS [package],
|
||||
[vJobReportForUser].[userProcess] AS [userProcess],
|
||||
[vJobReportForUser].[status] AS [status],
|
||||
[vJobReportForUser].[projectName] AS [projectName],
|
||||
[vJobReportForUser].[description] AS [description],
|
||||
[vJobReportForUser].[ww] AS [ww]
|
||||
FROM [dbo].[vJobReportForUser] AS [vJobReportForUser]</DefiningQuery>
|
||||
</EntitySet>
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="EEModelJobreport" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
<EntityType Name="JobReport">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pidx" Type="Int32" />
|
||||
<Property Name="projectName" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="uid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="requestpart" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="package" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="status" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="type" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="remark" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="hrs" Type="Double" />
|
||||
<Property Name="ot" Type="Double" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="description2" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="tag" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
|
||||
<Property Name="autoinput" Type="Boolean" />
|
||||
</EntityType>
|
||||
<EntityType Name="vJobReportForUser">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
<PropertyRef Name="gcode" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="id" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="type" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="svalue" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
|
||||
<Property Name="hrs" Type="Double" />
|
||||
<Property Name="ot" Type="Double" />
|
||||
<Property Name="requestpart" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="package" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="userProcess" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="status" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="projectName" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ww" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEEntitiesJobreport" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="JobReport" EntityType="Self.JobReport" />
|
||||
<EntitySet Name="vJobReportForUser" EntityType="Self.vJobReportForUser" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||
<EntityContainerMapping StorageEntityContainer="EEModelJobreportStoreContainer" CdmEntityContainer="EEEntitiesJobreport">
|
||||
<EntitySetMapping Name="JobReport">
|
||||
<EntityTypeMapping TypeName="EEModelJobreport.JobReport">
|
||||
<MappingFragment StoreEntitySet="JobReport">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="projectName" ColumnName="projectName" />
|
||||
<ScalarProperty Name="uid" ColumnName="uid" />
|
||||
<ScalarProperty Name="requestpart" ColumnName="requestpart" />
|
||||
<ScalarProperty Name="package" ColumnName="package" />
|
||||
<ScalarProperty Name="status" ColumnName="status" />
|
||||
<ScalarProperty Name="type" ColumnName="type" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="description" ColumnName="description" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="hrs" ColumnName="hrs" />
|
||||
<ScalarProperty Name="ot" ColumnName="ot" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="description2" ColumnName="description2" />
|
||||
<ScalarProperty Name="tag" ColumnName="tag" />
|
||||
<ScalarProperty Name="autoinput" ColumnName="autoinput" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="vJobReportForUser">
|
||||
<EntityTypeMapping TypeName="EEModelJobreport.vJobReportForUser">
|
||||
<MappingFragment StoreEntitySet="vJobReportForUser">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="type" ColumnName="type" />
|
||||
<ScalarProperty Name="svalue" ColumnName="svalue" />
|
||||
<ScalarProperty Name="hrs" ColumnName="hrs" />
|
||||
<ScalarProperty Name="ot" ColumnName="ot" />
|
||||
<ScalarProperty Name="requestpart" ColumnName="requestpart" />
|
||||
<ScalarProperty Name="package" ColumnName="package" />
|
||||
<ScalarProperty Name="userProcess" ColumnName="userProcess" />
|
||||
<ScalarProperty Name="status" ColumnName="status" />
|
||||
<ScalarProperty Name="projectName" ColumnName="projectName" />
|
||||
<ScalarProperty Name="description" ColumnName="description" />
|
||||
<ScalarProperty Name="ww" ColumnName="ww" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Connection>
|
||||
<Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="false" />
|
||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||
<DesignerProperty Name="CodeGenerationStrategy" Value="없음" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<Diagrams></Diagrams>
|
||||
</Designer>
|
||||
</edmx:Edmx>
|
||||
13
Project/ModelJobreport.edmx.diagram
Normal file
13
Project/ModelJobreport.edmx.diagram
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram DiagramId="d15b4808b6354697aa0b490304e8d3d7" Name="Diagram1">
|
||||
<EntityTypeShape EntityType="EEModelJobreport.JobReport" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelJobreport.vJobReportForUser" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
||||
733
Project/ModelJobreport.tt
Normal file
733
Project/ModelJobreport.tt
Normal file
@@ -0,0 +1,733 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelJobreport.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
WriteHeader(codeStringGenerator, fileManager);
|
||||
|
||||
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(entity.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||
{
|
||||
<#
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public <#=code.Escape(entity)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var navigationProperty in collectionNavigationProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach (var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(complexProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||
if (navigationProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach (var navigationProperty in navigationProperties)
|
||||
{
|
||||
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(complex.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||
{
|
||||
<#
|
||||
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
public <#=code.Escape(complex)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach(var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var edmProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#
|
||||
if (typeMapper.EnumIsFlags(enumType))
|
||||
{
|
||||
#>
|
||||
[Flags]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||
{
|
||||
<#
|
||||
var foundOne = false;
|
||||
|
||||
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||
{
|
||||
foundOne = true;
|
||||
#>
|
||||
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||
<#
|
||||
}
|
||||
|
||||
if (foundOne)
|
||||
{
|
||||
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
fileManager.Process();
|
||||
|
||||
#>
|
||||
<#+
|
||||
|
||||
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||
{
|
||||
fileManager.StartHeader();
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||
<#+
|
||||
fileManager.EndBlock();
|
||||
}
|
||||
|
||||
public void BeginNamespace(CodeGenerationTools code)
|
||||
{
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#+
|
||||
PushIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndNamespace(CodeGenerationTools code)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
37
Project/ModelProject.Context.cs
Normal file
37
Project/ModelProject.Context.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class EEEntitiesProject : DbContext
|
||||
{
|
||||
public EEEntitiesProject()
|
||||
: base("name=EEEntitiesProject")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
public virtual DbSet<EETGW_ProjecthistoryD> EETGW_ProjecthistoryD { get; set; }
|
||||
public virtual DbSet<EETGW_ProjectsSchedule> EETGW_ProjectsSchedule { get; set; }
|
||||
public virtual DbSet<EETGW_ProjectToDo> EETGW_ProjectToDo { get; set; }
|
||||
public virtual DbSet<Projects> Projects { get; set; }
|
||||
public virtual DbSet<ProjectsHistory> ProjectsHistory { get; set; }
|
||||
public virtual DbSet<ProjectsIOMap> ProjectsIOMap { get; set; }
|
||||
public virtual DbSet<ProjectsMailList> ProjectsMailList { get; set; }
|
||||
public virtual DbSet<ProjectsPart> ProjectsPart { get; set; }
|
||||
}
|
||||
}
|
||||
636
Project/ModelProject.Context.tt
Normal file
636
Project/ModelProject.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelProject.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||
if (container == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
<#
|
||||
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
}
|
||||
|
||||
#>
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
<#
|
||||
if (container.FunctionImports.Any())
|
||||
{
|
||||
#>
|
||||
using System.Data.Entity.Core.Objects;
|
||||
using System.Linq;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||
{
|
||||
public <#=code.Escape(container)#>()
|
||||
: base("name=<#=container.Name#>")
|
||||
{
|
||||
<#
|
||||
if (!loader.IsLazyLoadingEnabled(container))
|
||||
{
|
||||
#>
|
||||
this.Configuration.LazyLoadingEnabled = false;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
// Note: the DbSet members are defined below such that the getter and
|
||||
// setter always have the same accessibility as the DbSet definition
|
||||
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
<#
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var edmFunction in container.FunctionImports)
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
|
||||
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
if (typeMapper.IsComposable(edmFunction))
|
||||
{
|
||||
#>
|
||||
|
||||
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
|
||||
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
}
|
||||
<#+
|
||||
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||
{
|
||||
#>
|
||||
var <#=name#> = <#=isNotNull#> ?
|
||||
<#=notNullInit#> :
|
||||
<#=nullInit#>;
|
||||
|
||||
<#+
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string DbSetInitializer(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} = Set<{1}>();",
|
||||
_code.Escape(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
10
Project/ModelProject.Designer.cs
generated
Normal file
10
Project/ModelProject.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\Project\ModelProject.edmx'에 대해 T4 코드 생성이 사용됩니다.
|
||||
// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을
|
||||
// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때
|
||||
// 속성 창에서 사용할 수 있습니다.
|
||||
|
||||
// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만
|
||||
// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및
|
||||
// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한
|
||||
// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를
|
||||
// 선택하십시오.
|
||||
9
Project/ModelProject.cs
Normal file
9
Project/ModelProject.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
631
Project/ModelProject.edmx
Normal file
631
Project/ModelProject.edmx
Normal file
@@ -0,0 +1,631 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="EEModelProject.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="EETGW_ProjecthistoryD">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="div" Type="varchar" MaxLength="10" />
|
||||
<Property Name="remark" Type="varchar(max)" />
|
||||
<Property Name="remark2" Type="varchar(max)" />
|
||||
<Property Name="mailsend" Type="bit" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="EETGW_ProjectsSchedule">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="20" />
|
||||
<Property Name="project" Type="int" />
|
||||
<Property Name="seq" Type="int" />
|
||||
<Property Name="title" Type="varchar" MaxLength="100" />
|
||||
<Property Name="sw" Type="int" />
|
||||
<Property Name="ew" Type="int" />
|
||||
<Property Name="swa" Type="int" />
|
||||
<Property Name="ewa" Type="int" />
|
||||
<Property Name="uid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="memo" Type="varchar(max)" />
|
||||
<Property Name="progress" Type="int" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="EETGW_ProjectToDo">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" Nullable="false" />
|
||||
<Property Name="pseq" Type="int" />
|
||||
<Property Name="sw" Type="int" />
|
||||
<Property Name="ww" Type="int" />
|
||||
<Property Name="sort" Type="varchar" MaxLength="2" />
|
||||
<Property Name="cate" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="title" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="process" Type="int" />
|
||||
<Property Name="remark" Type="varchar(max)" />
|
||||
<Property Name="remark2" Type="varchar(max)" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Projects">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="isdel" Type="bit" />
|
||||
<Property Name="category" Type="varchar" MaxLength="50" />
|
||||
<Property Name="status" Type="varchar" MaxLength="50" />
|
||||
<Property Name="asset" Type="varchar" MaxLength="100" />
|
||||
<Property Name="level" Type="int" />
|
||||
<Property Name="rev" Type="int" />
|
||||
<Property Name="process" Type="varchar" MaxLength="50" />
|
||||
<Property Name="part" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="userManager" Type="varchar" MaxLength="50" />
|
||||
<Property Name="usermain" Type="varchar" MaxLength="50" />
|
||||
<Property Name="usersub" Type="varchar" MaxLength="50" />
|
||||
<Property Name="userhw2" Type="varchar" MaxLength="50" />
|
||||
<Property Name="reqstaff" Type="varchar" MaxLength="50" />
|
||||
<Property Name="costo" Type="float" />
|
||||
<Property Name="costn" Type="float" />
|
||||
<Property Name="cnt" Type="int" />
|
||||
<Property Name="remark_req" Type="varchar(max)" />
|
||||
<Property Name="remark_ans" Type="varchar(max)" />
|
||||
<Property Name="sdate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ddate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="odate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="progress" Type="int" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="orderno" Type="varchar" MaxLength="50" />
|
||||
<Property Name="crdue" Type="varchar" MaxLength="10" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="path" Type="varchar" MaxLength="300" />
|
||||
<Property Name="userprocess" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="CMP_Background" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_Description" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_Before" Type="nvarchar(max)" />
|
||||
<Property Name="CMP_After" Type="nvarchar(max)" />
|
||||
<Property Name="bCost" Type="bit" />
|
||||
<Property Name="bFanOut" Type="bit" />
|
||||
<Property Name="div" Type="varchar" MaxLength="2" />
|
||||
<Property Name="EB_Site" Type="varchar" MaxLength="20" />
|
||||
<Property Name="EB_Line" Type="varchar" MaxLength="10" />
|
||||
<Property Name="EB_Team" Type="varchar" MaxLength="10" />
|
||||
<Property Name="EB_Model" Type="varchar" MaxLength="100" />
|
||||
<Property Name="EB_OutSourceName" Type="varchar" MaxLength="100" />
|
||||
<Property Name="EB_RepairTime" Type="float" />
|
||||
<Property Name="EB_ConstNew" Type="float" />
|
||||
<Property Name="EB_BoardName" Type="nvarchar" MaxLength="255" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="pidx" Type="int" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="div" Type="varchar" MaxLength="10" />
|
||||
<Property Name="remark" Type="varchar(max)" />
|
||||
<Property Name="remark2" Type="varchar(max)" />
|
||||
<Property Name="mailsend" Type="bit" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsIOMap">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="Dir" Type="varchar" MaxLength="20" />
|
||||
<Property Name="PIn" Type="varchar" MaxLength="100" />
|
||||
<Property Name="Description" Type="varchar" MaxLength="100" />
|
||||
<Property Name="Remark" Type="varchar" MaxLength="100" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsMailList">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="enable" Type="bit" />
|
||||
<Property Name="div" Type="varchar" MaxLength="10" />
|
||||
<Property Name="name" Type="varchar" MaxLength="100" />
|
||||
<Property Name="address" Type="varchar" MaxLength="255" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsPart">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="no" Type="int" />
|
||||
<Property Name="Project" Type="int" />
|
||||
<Property Name="ItemGroup" Type="varchar" MaxLength="100" />
|
||||
<Property Name="ItemModel" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="ItemUnit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ItemName" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="ItemSid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="ItemSupply" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="ItemSupplyidx" Type="int" />
|
||||
<Property Name="ItemManu" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="Item" Type="int" />
|
||||
<Property Name="option1" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="option2" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="option3" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="qty" Type="int" />
|
||||
<Property Name="qtyn" Type="int" />
|
||||
<Property Name="price" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amt" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amtn" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="jago" Type="int" />
|
||||
<Property Name="remark" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="qtyjago" Type="varchar" MaxLength="50" />
|
||||
<Property Name="qtybuy" Type="int" />
|
||||
<Property Name="qtyin" Type="int" />
|
||||
<Property Name="bbuy" Type="bit" />
|
||||
<Property Name="bconfirm" Type="bit" />
|
||||
<Property Name="bCancel" Type="bit" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEModelProjectStoreContainer">
|
||||
<EntitySet Name="EETGW_ProjecthistoryD" EntityType="Self.EETGW_ProjecthistoryD" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="EETGW_ProjectsSchedule" EntityType="Self.EETGW_ProjectsSchedule" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="EETGW_ProjectToDo" EntityType="Self.EETGW_ProjectToDo" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Projects" EntityType="Self.Projects" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsHistory" EntityType="Self.ProjectsHistory" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsIOMap" EntityType="Self.ProjectsIOMap" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsMailList" EntityType="Self.ProjectsMailList" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProjectsPart" EntityType="Self.ProjectsPart" Schema="dbo" store:Type="Tables" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="EEModelProject" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
<EntityType Name="EETGW_ProjecthistoryD">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="div" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark2" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="mailsend" Type="Boolean" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="EETGW_ProjectsSchedule">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="gcode" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="project" Type="Int32" />
|
||||
<Property Name="seq" Type="Int32" />
|
||||
<Property Name="title" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sw" Type="Int32" />
|
||||
<Property Name="ew" Type="Int32" />
|
||||
<Property Name="swa" Type="Int32" />
|
||||
<Property Name="ewa" Type="Int32" />
|
||||
<Property Name="uid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="memo" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="progress" Type="Int32" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="EETGW_ProjectToDo">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" Nullable="false" />
|
||||
<Property Name="pseq" Type="Int32" />
|
||||
<Property Name="sw" Type="Int32" />
|
||||
<Property Name="ww" Type="Int32" />
|
||||
<Property Name="sort" Type="String" MaxLength="2" FixedLength="false" Unicode="false" />
|
||||
<Property Name="cate" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="title" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="process" Type="Int32" />
|
||||
<Property Name="remark" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark2" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="Projects">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="isdel" Type="Boolean" />
|
||||
<Property Name="category" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="status" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="asset" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="level" Type="Int32" />
|
||||
<Property Name="rev" Type="Int32" />
|
||||
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="part" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="userManager" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="usermain" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="usersub" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="userhw2" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="reqstaff" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="costo" Type="Double" />
|
||||
<Property Name="costn" Type="Double" />
|
||||
<Property Name="cnt" Type="Int32" />
|
||||
<Property Name="remark_req" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark_ans" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sdate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ddate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="odate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="progress" Type="Int32" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="orderno" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="crdue" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="path" Type="String" MaxLength="300" FixedLength="false" Unicode="false" />
|
||||
<Property Name="userprocess" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Background" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_Before" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="CMP_After" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
|
||||
<Property Name="bCost" Type="Boolean" />
|
||||
<Property Name="bFanOut" Type="Boolean" />
|
||||
<Property Name="div" Type="String" MaxLength="2" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Site" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Line" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Team" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_Model" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_OutSourceName" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="EB_RepairTime" Type="Double" />
|
||||
<Property Name="EB_ConstNew" Type="Double" />
|
||||
<Property Name="EB_BoardName" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="pidx" Type="Int32" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="div" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="remark2" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="mailsend" Type="Boolean" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsIOMap">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="Dir" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="PIn" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="Description" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="Remark" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsMailList">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="enable" Type="Boolean" />
|
||||
<Property Name="div" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="address" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProjectsPart">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="no" Type="Int32" />
|
||||
<Property Name="Project" Type="Int32" />
|
||||
<Property Name="ItemGroup" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemModel" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemUnit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemName" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemSid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="ItemSupply" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="ItemSupplyidx" Type="Int32" />
|
||||
<Property Name="ItemManu" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="Item" Type="Int32" />
|
||||
<Property Name="option1" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="option2" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="option3" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="qty" Type="Int32" />
|
||||
<Property Name="qtyn" Type="Int32" />
|
||||
<Property Name="price" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amt" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="amtn" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="jago" Type="Int32" />
|
||||
<Property Name="remark" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="qtyjago" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="qtybuy" Type="Int32" />
|
||||
<Property Name="qtyin" Type="Int32" />
|
||||
<Property Name="bbuy" Type="Boolean" />
|
||||
<Property Name="bconfirm" Type="Boolean" />
|
||||
<Property Name="bCancel" Type="Boolean" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEEntitiesProject" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="EETGW_ProjecthistoryD" EntityType="Self.EETGW_ProjecthistoryD" />
|
||||
<EntitySet Name="EETGW_ProjectsSchedule" EntityType="Self.EETGW_ProjectsSchedule" />
|
||||
<EntitySet Name="EETGW_ProjectToDo" EntityType="Self.EETGW_ProjectToDo" />
|
||||
<EntitySet Name="Projects" EntityType="Self.Projects" />
|
||||
<EntitySet Name="ProjectsHistory" EntityType="Self.ProjectsHistory" />
|
||||
<EntitySet Name="ProjectsIOMap" EntityType="Self.ProjectsIOMap" />
|
||||
<EntitySet Name="ProjectsMailList" EntityType="Self.ProjectsMailList" />
|
||||
<EntitySet Name="ProjectsPart" EntityType="Self.ProjectsPart" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||
<EntityContainerMapping StorageEntityContainer="EEModelProjectStoreContainer" CdmEntityContainer="EEEntitiesProject">
|
||||
<EntitySetMapping Name="EETGW_ProjecthistoryD">
|
||||
<EntityTypeMapping TypeName="EEModelProject.EETGW_ProjecthistoryD">
|
||||
<MappingFragment StoreEntitySet="EETGW_ProjecthistoryD">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="remark2" ColumnName="remark2" />
|
||||
<ScalarProperty Name="mailsend" ColumnName="mailsend" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="EETGW_ProjectsSchedule">
|
||||
<EntityTypeMapping TypeName="EEModelProject.EETGW_ProjectsSchedule">
|
||||
<MappingFragment StoreEntitySet="EETGW_ProjectsSchedule">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="project" ColumnName="project" />
|
||||
<ScalarProperty Name="seq" ColumnName="seq" />
|
||||
<ScalarProperty Name="title" ColumnName="title" />
|
||||
<ScalarProperty Name="sw" ColumnName="sw" />
|
||||
<ScalarProperty Name="ew" ColumnName="ew" />
|
||||
<ScalarProperty Name="swa" ColumnName="swa" />
|
||||
<ScalarProperty Name="ewa" ColumnName="ewa" />
|
||||
<ScalarProperty Name="uid" ColumnName="uid" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="progress" ColumnName="progress" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="EETGW_ProjectToDo">
|
||||
<EntityTypeMapping TypeName="EEModelProject.EETGW_ProjectToDo">
|
||||
<MappingFragment StoreEntitySet="EETGW_ProjectToDo">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="pseq" ColumnName="pseq" />
|
||||
<ScalarProperty Name="sw" ColumnName="sw" />
|
||||
<ScalarProperty Name="ww" ColumnName="ww" />
|
||||
<ScalarProperty Name="sort" ColumnName="sort" />
|
||||
<ScalarProperty Name="cate" ColumnName="cate" />
|
||||
<ScalarProperty Name="title" ColumnName="title" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="remark2" ColumnName="remark2" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Projects">
|
||||
<EntityTypeMapping TypeName="EEModelProject.Projects">
|
||||
<MappingFragment StoreEntitySet="Projects">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="isdel" ColumnName="isdel" />
|
||||
<ScalarProperty Name="category" ColumnName="category" />
|
||||
<ScalarProperty Name="status" ColumnName="status" />
|
||||
<ScalarProperty Name="asset" ColumnName="asset" />
|
||||
<ScalarProperty Name="level" ColumnName="level" />
|
||||
<ScalarProperty Name="rev" ColumnName="rev" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="part" ColumnName="part" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="userManager" ColumnName="userManager" />
|
||||
<ScalarProperty Name="usermain" ColumnName="usermain" />
|
||||
<ScalarProperty Name="usersub" ColumnName="usersub" />
|
||||
<ScalarProperty Name="userhw2" ColumnName="userhw2" />
|
||||
<ScalarProperty Name="reqstaff" ColumnName="reqstaff" />
|
||||
<ScalarProperty Name="costo" ColumnName="costo" />
|
||||
<ScalarProperty Name="costn" ColumnName="costn" />
|
||||
<ScalarProperty Name="cnt" ColumnName="cnt" />
|
||||
<ScalarProperty Name="remark_req" ColumnName="remark_req" />
|
||||
<ScalarProperty Name="remark_ans" ColumnName="remark_ans" />
|
||||
<ScalarProperty Name="sdate" ColumnName="sdate" />
|
||||
<ScalarProperty Name="ddate" ColumnName="ddate" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="odate" ColumnName="odate" />
|
||||
<ScalarProperty Name="progress" ColumnName="progress" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="orderno" ColumnName="orderno" />
|
||||
<ScalarProperty Name="crdue" ColumnName="crdue" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="path" ColumnName="path" />
|
||||
<ScalarProperty Name="userprocess" ColumnName="userprocess" />
|
||||
<ScalarProperty Name="CMP_Background" ColumnName="CMP_Background" />
|
||||
<ScalarProperty Name="CMP_Description" ColumnName="CMP_Description" />
|
||||
<ScalarProperty Name="CMP_Before" ColumnName="CMP_Before" />
|
||||
<ScalarProperty Name="CMP_After" ColumnName="CMP_After" />
|
||||
<ScalarProperty Name="bCost" ColumnName="bCost" />
|
||||
<ScalarProperty Name="bFanOut" ColumnName="bFanOut" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="EB_Site" ColumnName="EB_Site" />
|
||||
<ScalarProperty Name="EB_Line" ColumnName="EB_Line" />
|
||||
<ScalarProperty Name="EB_Team" ColumnName="EB_Team" />
|
||||
<ScalarProperty Name="EB_Model" ColumnName="EB_Model" />
|
||||
<ScalarProperty Name="EB_OutSourceName" ColumnName="EB_OutSourceName" />
|
||||
<ScalarProperty Name="EB_RepairTime" ColumnName="EB_RepairTime" />
|
||||
<ScalarProperty Name="EB_ConstNew" ColumnName="EB_ConstNew" />
|
||||
<ScalarProperty Name="EB_BoardName" ColumnName="EB_BoardName" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsHistory">
|
||||
<EntityTypeMapping TypeName="EEModelProject.ProjectsHistory">
|
||||
<MappingFragment StoreEntitySet="ProjectsHistory">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="pidx" ColumnName="pidx" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="remark2" ColumnName="remark2" />
|
||||
<ScalarProperty Name="mailsend" ColumnName="mailsend" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsIOMap">
|
||||
<EntityTypeMapping TypeName="EEModelProject.ProjectsIOMap">
|
||||
<MappingFragment StoreEntitySet="ProjectsIOMap">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="Dir" ColumnName="Dir" />
|
||||
<ScalarProperty Name="PIn" ColumnName="PIn" />
|
||||
<ScalarProperty Name="Description" ColumnName="Description" />
|
||||
<ScalarProperty Name="Remark" ColumnName="Remark" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsMailList">
|
||||
<EntityTypeMapping TypeName="EEModelProject.ProjectsMailList">
|
||||
<MappingFragment StoreEntitySet="ProjectsMailList">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="enable" ColumnName="enable" />
|
||||
<ScalarProperty Name="div" ColumnName="div" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="address" ColumnName="address" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProjectsPart">
|
||||
<EntityTypeMapping TypeName="EEModelProject.ProjectsPart">
|
||||
<MappingFragment StoreEntitySet="ProjectsPart">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="no" ColumnName="no" />
|
||||
<ScalarProperty Name="Project" ColumnName="Project" />
|
||||
<ScalarProperty Name="ItemGroup" ColumnName="ItemGroup" />
|
||||
<ScalarProperty Name="ItemModel" ColumnName="ItemModel" />
|
||||
<ScalarProperty Name="ItemUnit" ColumnName="ItemUnit" />
|
||||
<ScalarProperty Name="ItemName" ColumnName="ItemName" />
|
||||
<ScalarProperty Name="ItemSid" ColumnName="ItemSid" />
|
||||
<ScalarProperty Name="ItemSupply" ColumnName="ItemSupply" />
|
||||
<ScalarProperty Name="ItemSupplyidx" ColumnName="ItemSupplyidx" />
|
||||
<ScalarProperty Name="ItemManu" ColumnName="ItemManu" />
|
||||
<ScalarProperty Name="Item" ColumnName="Item" />
|
||||
<ScalarProperty Name="option1" ColumnName="option1" />
|
||||
<ScalarProperty Name="option2" ColumnName="option2" />
|
||||
<ScalarProperty Name="option3" ColumnName="option3" />
|
||||
<ScalarProperty Name="qty" ColumnName="qty" />
|
||||
<ScalarProperty Name="qtyn" ColumnName="qtyn" />
|
||||
<ScalarProperty Name="price" ColumnName="price" />
|
||||
<ScalarProperty Name="amt" ColumnName="amt" />
|
||||
<ScalarProperty Name="amtn" ColumnName="amtn" />
|
||||
<ScalarProperty Name="jago" ColumnName="jago" />
|
||||
<ScalarProperty Name="remark" ColumnName="remark" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="qtyjago" ColumnName="qtyjago" />
|
||||
<ScalarProperty Name="qtybuy" ColumnName="qtybuy" />
|
||||
<ScalarProperty Name="qtyin" ColumnName="qtyin" />
|
||||
<ScalarProperty Name="bbuy" ColumnName="bbuy" />
|
||||
<ScalarProperty Name="bconfirm" ColumnName="bconfirm" />
|
||||
<ScalarProperty Name="bCancel" ColumnName="bCancel" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Connection>
|
||||
<Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="false" />
|
||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||
<DesignerProperty Name="CodeGenerationStrategy" Value="없음" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<Diagrams></Diagrams>
|
||||
</Designer>
|
||||
</edmx:Edmx>
|
||||
19
Project/ModelProject.edmx.diagram
Normal file
19
Project/ModelProject.edmx.diagram
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram DiagramId="e2d85008b4ed4fe5b32f2efa574b1ec7" Name="Diagram1">
|
||||
<EntityTypeShape EntityType="EEModelProject.EETGW_ProjecthistoryD" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.EETGW_ProjectsSchedule" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.EETGW_ProjectToDo" Width="1.5" PointX="4.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.Projects" Width="1.5" PointX="0.75" PointY="5.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.ProjectsHistory" Width="1.5" PointX="2.75" PointY="5.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.ProjectsIOMap" Width="1.5" PointX="4.75" PointY="5.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.ProjectsMailList" Width="1.5" PointX="6.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModelProject.ProjectsPart" Width="1.5" PointX="6.75" PointY="4.75" IsExpanded="true" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
||||
733
Project/ModelProject.tt
Normal file
733
Project/ModelProject.tt
Normal file
@@ -0,0 +1,733 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelProject.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
WriteHeader(codeStringGenerator, fileManager);
|
||||
|
||||
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(entity.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||
{
|
||||
<#
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public <#=code.Escape(entity)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var navigationProperty in collectionNavigationProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach (var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(complexProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||
if (navigationProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach (var navigationProperty in navigationProperties)
|
||||
{
|
||||
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(complex.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||
{
|
||||
<#
|
||||
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
public <#=code.Escape(complex)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach(var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var edmProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#
|
||||
if (typeMapper.EnumIsFlags(enumType))
|
||||
{
|
||||
#>
|
||||
[Flags]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||
{
|
||||
<#
|
||||
var foundOne = false;
|
||||
|
||||
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||
{
|
||||
foundOne = true;
|
||||
#>
|
||||
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||
<#
|
||||
}
|
||||
|
||||
if (foundOne)
|
||||
{
|
||||
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
fileManager.Process();
|
||||
|
||||
#>
|
||||
<#+
|
||||
|
||||
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||
{
|
||||
fileManager.StartHeader();
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||
<#+
|
||||
fileManager.EndBlock();
|
||||
}
|
||||
|
||||
public void BeginNamespace(CodeGenerationTools code)
|
||||
{
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#+
|
||||
PushIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndNamespace(CodeGenerationTools code)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
32
Project/ModelPurchase.Context.cs
Normal file
32
Project/ModelPurchase.Context.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class EEEntitiesPurchase : DbContext
|
||||
{
|
||||
public EEEntitiesPurchase()
|
||||
: base("name=EEEntitiesPurchase")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
public virtual DbSet<Items> Items { get; set; }
|
||||
public virtual DbSet<Purchase> Purchase { get; set; }
|
||||
public virtual DbSet<vPurchase> vPurchase { get; set; }
|
||||
}
|
||||
}
|
||||
636
Project/ModelPurchase.Context.tt
Normal file
636
Project/ModelPurchase.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelPurchase.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||
if (container == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
<#
|
||||
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
}
|
||||
|
||||
#>
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
<#
|
||||
if (container.FunctionImports.Any())
|
||||
{
|
||||
#>
|
||||
using System.Data.Entity.Core.Objects;
|
||||
using System.Linq;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||
{
|
||||
public <#=code.Escape(container)#>()
|
||||
: base("name=<#=container.Name#>")
|
||||
{
|
||||
<#
|
||||
if (!loader.IsLazyLoadingEnabled(container))
|
||||
{
|
||||
#>
|
||||
this.Configuration.LazyLoadingEnabled = false;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
// Note: the DbSet members are defined below such that the getter and
|
||||
// setter always have the same accessibility as the DbSet definition
|
||||
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
<#
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var edmFunction in container.FunctionImports)
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
|
||||
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
if (typeMapper.IsComposable(edmFunction))
|
||||
{
|
||||
#>
|
||||
|
||||
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
|
||||
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
}
|
||||
<#+
|
||||
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||
{
|
||||
#>
|
||||
var <#=name#> = <#=isNotNull#> ?
|
||||
<#=notNullInit#> :
|
||||
<#=nullInit#>;
|
||||
|
||||
<#+
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string DbSetInitializer(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} = Set<{1}>();",
|
||||
_code.Escape(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
10
Project/ModelPurchase.Designer.cs
generated
Normal file
10
Project/ModelPurchase.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\Project\ModelPurchase.edmx'에 대해 T4 코드 생성이 사용됩니다.
|
||||
// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을
|
||||
// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때
|
||||
// 속성 창에서 사용할 수 있습니다.
|
||||
|
||||
// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만
|
||||
// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및
|
||||
// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한
|
||||
// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를
|
||||
// 선택하십시오.
|
||||
9
Project/ModelPurchase.cs
Normal file
9
Project/ModelPurchase.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
418
Project/ModelPurchase.edmx
Normal file
418
Project/ModelPurchase.edmx
Normal file
@@ -0,0 +1,418 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="EEModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="Items">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="disable" Type="bit" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" />
|
||||
<Property Name="cate" Type="varchar" MaxLength="50" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="sid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="model" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="manu" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="scale" Type="float" />
|
||||
<Property Name="unit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="supply" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="supplyidx" Type="int" />
|
||||
<Property Name="price" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="memo" Type="nvarchar" MaxLength="255" />
|
||||
<Property Name="image" Type="varbinary(max)" />
|
||||
<Property Name="bparam1" Type="bit" />
|
||||
<Property Name="iparam1" Type="int" />
|
||||
<Property Name="import" Type="char" MaxLength="1" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="bEstimate" Type="bit" />
|
||||
<Property Name="bSAP" Type="bit" />
|
||||
</EntityType>
|
||||
<EntityType Name="Purchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="state" Type="varchar" MaxLength="30" />
|
||||
<Property Name="process" Type="varchar" MaxLength="30" />
|
||||
<Property Name="receive" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sc" Type="varchar" MaxLength="30" />
|
||||
<Property Name="request" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumname" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="pumidx" Type="int" />
|
||||
<Property Name="pumscale" Type="varchar" MaxLength="200" />
|
||||
<Property Name="pumunit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumqty" Type="int" />
|
||||
<Property Name="pumprice" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="varchar" MaxLength="200" />
|
||||
<Property Name="supplyidx" Type="int" />
|
||||
<Property Name="project" Type="varchar(max)" />
|
||||
<Property Name="projectidx" Type="int" />
|
||||
<Property Name="asset" Type="varchar" MaxLength="50" />
|
||||
<Property Name="manuproc" Type="varchar" MaxLength="50" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="indate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="po" Type="varchar" MaxLength="50" />
|
||||
<Property Name="dept" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="bigo" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="isdel" Type="bit" />
|
||||
<Property Name="orderno" Type="varchar" MaxLength="50" />
|
||||
<Property Name="place" Type="varchar" MaxLength="20" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="inqty" Type="int" />
|
||||
</EntityType>
|
||||
<!--생성 중 오류 발생:
|
||||
경고 6002: 테이블/뷰 'EE.dbo.vPurchase'에 기본 키가 정의되지 않았습니다. 키가 유추되었고 읽기 전용 테이블/뷰로 정의되었습니다.-->
|
||||
<EntityType Name="vPurchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
<PropertyRef Name="gcode" />
|
||||
<PropertyRef Name="wuid" />
|
||||
<PropertyRef Name="wdate" />
|
||||
</Key>
|
||||
<Property Name="name" Type="nvarchar" MaxLength="100" />
|
||||
<Property Name="idx" Type="int" Nullable="false" />
|
||||
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
|
||||
<Property Name="pdate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="state" Type="varchar" MaxLength="30" />
|
||||
<Property Name="process" Type="varchar" MaxLength="30" />
|
||||
<Property Name="receive" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sc" Type="varchar" MaxLength="30" />
|
||||
<Property Name="request" Type="varchar" MaxLength="50" />
|
||||
<Property Name="sid" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumname" Type="nvarchar" MaxLength="200" />
|
||||
<Property Name="pumidx" Type="int" />
|
||||
<Property Name="pumscale" Type="varchar" MaxLength="200" />
|
||||
<Property Name="pumunit" Type="varchar" MaxLength="50" />
|
||||
<Property Name="pumqty" Type="int" />
|
||||
<Property Name="pumprice" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="varchar" MaxLength="200" />
|
||||
<Property Name="supplyidx" Type="int" />
|
||||
<Property Name="project" Type="varchar(max)" />
|
||||
<Property Name="projectidx" Type="int" />
|
||||
<Property Name="asset" Type="varchar" MaxLength="50" />
|
||||
<Property Name="manuproc" Type="varchar" MaxLength="50" />
|
||||
<Property Name="edate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="indate" Type="varchar" MaxLength="10" />
|
||||
<Property Name="po" Type="varchar" MaxLength="50" />
|
||||
<Property Name="dept" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="bigo" Type="nvarchar" MaxLength="500" />
|
||||
<Property Name="import" Type="bit" />
|
||||
<Property Name="isdel" Type="bit" />
|
||||
<Property Name="orderno" Type="varchar" MaxLength="50" />
|
||||
<Property Name="place" Type="varchar" MaxLength="20" />
|
||||
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
|
||||
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
|
||||
<Property Name="inqty" Type="int" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEModelStoreContainer">
|
||||
<EntitySet Name="Items" EntityType="Self.Items" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Purchase" EntityType="Self.Purchase" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="vPurchase" EntityType="Self.vPurchase" store:Type="Views" store:Schema="dbo">
|
||||
<DefiningQuery>SELECT
|
||||
[vPurchase].[name] AS [name],
|
||||
[vPurchase].[idx] AS [idx],
|
||||
[vPurchase].[gcode] AS [gcode],
|
||||
[vPurchase].[pdate] AS [pdate],
|
||||
[vPurchase].[state] AS [state],
|
||||
[vPurchase].[process] AS [process],
|
||||
[vPurchase].[receive] AS [receive],
|
||||
[vPurchase].[sc] AS [sc],
|
||||
[vPurchase].[request] AS [request],
|
||||
[vPurchase].[sid] AS [sid],
|
||||
[vPurchase].[pumname] AS [pumname],
|
||||
[vPurchase].[pumidx] AS [pumidx],
|
||||
[vPurchase].[pumscale] AS [pumscale],
|
||||
[vPurchase].[pumunit] AS [pumunit],
|
||||
[vPurchase].[pumqty] AS [pumqty],
|
||||
[vPurchase].[pumprice] AS [pumprice],
|
||||
[vPurchase].[pumamt] AS [pumamt],
|
||||
[vPurchase].[supply] AS [supply],
|
||||
[vPurchase].[supplyidx] AS [supplyidx],
|
||||
[vPurchase].[project] AS [project],
|
||||
[vPurchase].[projectidx] AS [projectidx],
|
||||
[vPurchase].[asset] AS [asset],
|
||||
[vPurchase].[manuproc] AS [manuproc],
|
||||
[vPurchase].[edate] AS [edate],
|
||||
[vPurchase].[indate] AS [indate],
|
||||
[vPurchase].[po] AS [po],
|
||||
[vPurchase].[dept] AS [dept],
|
||||
[vPurchase].[bigo] AS [bigo],
|
||||
[vPurchase].[import] AS [import],
|
||||
[vPurchase].[isdel] AS [isdel],
|
||||
[vPurchase].[orderno] AS [orderno],
|
||||
[vPurchase].[place] AS [place],
|
||||
[vPurchase].[wuid] AS [wuid],
|
||||
[vPurchase].[wdate] AS [wdate],
|
||||
[vPurchase].[inqty] AS [inqty]
|
||||
FROM [dbo].[vPurchase] AS [vPurchase]</DefiningQuery>
|
||||
</EntitySet>
|
||||
</EntityContainer>
|
||||
</Schema></edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="EEModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
<EntityType Name="Items">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="disable" Type="Boolean" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="cate" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="name" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="sid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="model" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="manu" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="scale" Type="Double" />
|
||||
<Property Name="unit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="supply" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="supplyidx" Type="Int32" />
|
||||
<Property Name="price" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
|
||||
<Property Name="image" Type="Binary" MaxLength="Max" FixedLength="false" />
|
||||
<Property Name="bparam1" Type="Boolean" />
|
||||
<Property Name="iparam1" Type="Int32" />
|
||||
<Property Name="import" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="bEstimate" Type="Boolean" />
|
||||
<Property Name="bSAP" Type="Boolean" />
|
||||
</EntityType>
|
||||
<EntityType Name="Purchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
</Key>
|
||||
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="state" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="process" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="receive" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sc" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="request" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumname" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="pumidx" Type="Int32" />
|
||||
<Property Name="pumscale" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumunit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumqty" Type="Int32" />
|
||||
<Property Name="pumprice" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="supplyidx" Type="Int32" />
|
||||
<Property Name="project" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="projectidx" Type="Int32" />
|
||||
<Property Name="asset" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="manuproc" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="indate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="po" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="dept" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="bigo" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="isdel" Type="Boolean" />
|
||||
<Property Name="orderno" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="place" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="inqty" Type="Int32" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="EEEntitiesPurchase" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="Items" EntityType="Self.Items" />
|
||||
<EntitySet Name="Purchase" EntityType="Self.Purchase" />
|
||||
<EntitySet Name="vPurchase" EntityType="EEModel.vPurchase" />
|
||||
</EntityContainer>
|
||||
<EntityType Name="vPurchase">
|
||||
<Key>
|
||||
<PropertyRef Name="idx" />
|
||||
<PropertyRef Name="gcode" />
|
||||
<PropertyRef Name="wuid" />
|
||||
<PropertyRef Name="wdate" />
|
||||
</Key>
|
||||
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
|
||||
<Property Name="idx" Type="Int32" Nullable="false" />
|
||||
<Property Name="gcode" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="state" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="process" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="receive" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sc" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
|
||||
<Property Name="request" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="sid" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumname" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
|
||||
<Property Name="pumidx" Type="Int32" />
|
||||
<Property Name="pumscale" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumunit" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="pumqty" Type="Int32" />
|
||||
<Property Name="pumprice" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="pumamt" Type="Decimal" Precision="18" Scale="0" />
|
||||
<Property Name="supply" Type="String" MaxLength="200" FixedLength="false" Unicode="false" />
|
||||
<Property Name="supplyidx" Type="Int32" />
|
||||
<Property Name="project" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
|
||||
<Property Name="projectidx" Type="Int32" />
|
||||
<Property Name="asset" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="manuproc" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="edate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="indate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
|
||||
<Property Name="po" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="dept" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="bigo" Type="String" MaxLength="500" FixedLength="false" Unicode="true" />
|
||||
<Property Name="import" Type="Boolean" />
|
||||
<Property Name="isdel" Type="Boolean" />
|
||||
<Property Name="orderno" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
|
||||
<Property Name="place" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
|
||||
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
|
||||
<Property Name="inqty" Type="Int32" />
|
||||
</EntityType>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||
<EntityContainerMapping StorageEntityContainer="EEModelStoreContainer" CdmEntityContainer="EEEntitiesPurchase">
|
||||
<EntitySetMapping Name="Items">
|
||||
<EntityTypeMapping TypeName="EEModel.Items">
|
||||
<MappingFragment StoreEntitySet="Items">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="disable" ColumnName="disable" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="cate" ColumnName="cate" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="sid" ColumnName="sid" />
|
||||
<ScalarProperty Name="model" ColumnName="model" />
|
||||
<ScalarProperty Name="manu" ColumnName="manu" />
|
||||
<ScalarProperty Name="scale" ColumnName="scale" />
|
||||
<ScalarProperty Name="unit" ColumnName="unit" />
|
||||
<ScalarProperty Name="supply" ColumnName="supply" />
|
||||
<ScalarProperty Name="supplyidx" ColumnName="supplyidx" />
|
||||
<ScalarProperty Name="price" ColumnName="price" />
|
||||
<ScalarProperty Name="memo" ColumnName="memo" />
|
||||
<ScalarProperty Name="image" ColumnName="image" />
|
||||
<ScalarProperty Name="bparam1" ColumnName="bparam1" />
|
||||
<ScalarProperty Name="iparam1" ColumnName="iparam1" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="bEstimate" ColumnName="bEstimate" />
|
||||
<ScalarProperty Name="bSAP" ColumnName="bSAP" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Purchase">
|
||||
<EntityTypeMapping TypeName="EEModel.Purchase">
|
||||
<MappingFragment StoreEntitySet="Purchase">
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="state" ColumnName="state" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="receive" ColumnName="receive" />
|
||||
<ScalarProperty Name="sc" ColumnName="sc" />
|
||||
<ScalarProperty Name="request" ColumnName="request" />
|
||||
<ScalarProperty Name="sid" ColumnName="sid" />
|
||||
<ScalarProperty Name="pumname" ColumnName="pumname" />
|
||||
<ScalarProperty Name="pumidx" ColumnName="pumidx" />
|
||||
<ScalarProperty Name="pumscale" ColumnName="pumscale" />
|
||||
<ScalarProperty Name="pumunit" ColumnName="pumunit" />
|
||||
<ScalarProperty Name="pumqty" ColumnName="pumqty" />
|
||||
<ScalarProperty Name="pumprice" ColumnName="pumprice" />
|
||||
<ScalarProperty Name="pumamt" ColumnName="pumamt" />
|
||||
<ScalarProperty Name="supply" ColumnName="supply" />
|
||||
<ScalarProperty Name="supplyidx" ColumnName="supplyidx" />
|
||||
<ScalarProperty Name="project" ColumnName="project" />
|
||||
<ScalarProperty Name="projectidx" ColumnName="projectidx" />
|
||||
<ScalarProperty Name="asset" ColumnName="asset" />
|
||||
<ScalarProperty Name="manuproc" ColumnName="manuproc" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="indate" ColumnName="indate" />
|
||||
<ScalarProperty Name="po" ColumnName="po" />
|
||||
<ScalarProperty Name="dept" ColumnName="dept" />
|
||||
<ScalarProperty Name="bigo" ColumnName="bigo" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="isdel" ColumnName="isdel" />
|
||||
<ScalarProperty Name="orderno" ColumnName="orderno" />
|
||||
<ScalarProperty Name="place" ColumnName="place" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="inqty" ColumnName="inqty" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="vPurchase">
|
||||
<EntityTypeMapping TypeName="EEModel.vPurchase">
|
||||
<MappingFragment StoreEntitySet="vPurchase">
|
||||
<ScalarProperty Name="inqty" ColumnName="inqty" />
|
||||
<ScalarProperty Name="wdate" ColumnName="wdate" />
|
||||
<ScalarProperty Name="wuid" ColumnName="wuid" />
|
||||
<ScalarProperty Name="place" ColumnName="place" />
|
||||
<ScalarProperty Name="orderno" ColumnName="orderno" />
|
||||
<ScalarProperty Name="isdel" ColumnName="isdel" />
|
||||
<ScalarProperty Name="import" ColumnName="import" />
|
||||
<ScalarProperty Name="bigo" ColumnName="bigo" />
|
||||
<ScalarProperty Name="dept" ColumnName="dept" />
|
||||
<ScalarProperty Name="po" ColumnName="po" />
|
||||
<ScalarProperty Name="indate" ColumnName="indate" />
|
||||
<ScalarProperty Name="edate" ColumnName="edate" />
|
||||
<ScalarProperty Name="manuproc" ColumnName="manuproc" />
|
||||
<ScalarProperty Name="asset" ColumnName="asset" />
|
||||
<ScalarProperty Name="projectidx" ColumnName="projectidx" />
|
||||
<ScalarProperty Name="project" ColumnName="project" />
|
||||
<ScalarProperty Name="supplyidx" ColumnName="supplyidx" />
|
||||
<ScalarProperty Name="supply" ColumnName="supply" />
|
||||
<ScalarProperty Name="pumamt" ColumnName="pumamt" />
|
||||
<ScalarProperty Name="pumprice" ColumnName="pumprice" />
|
||||
<ScalarProperty Name="pumqty" ColumnName="pumqty" />
|
||||
<ScalarProperty Name="pumunit" ColumnName="pumunit" />
|
||||
<ScalarProperty Name="pumscale" ColumnName="pumscale" />
|
||||
<ScalarProperty Name="pumidx" ColumnName="pumidx" />
|
||||
<ScalarProperty Name="pumname" ColumnName="pumname" />
|
||||
<ScalarProperty Name="sid" ColumnName="sid" />
|
||||
<ScalarProperty Name="request" ColumnName="request" />
|
||||
<ScalarProperty Name="sc" ColumnName="sc" />
|
||||
<ScalarProperty Name="receive" ColumnName="receive" />
|
||||
<ScalarProperty Name="process" ColumnName="process" />
|
||||
<ScalarProperty Name="state" ColumnName="state" />
|
||||
<ScalarProperty Name="pdate" ColumnName="pdate" />
|
||||
<ScalarProperty Name="gcode" ColumnName="gcode" />
|
||||
<ScalarProperty Name="idx" ColumnName="idx" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Connection>
|
||||
<Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="false" />
|
||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||
<DesignerProperty Name="CodeGenerationStrategy" Value="없음" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<Diagrams></Diagrams>
|
||||
</Designer>
|
||||
</edmx:Edmx>
|
||||
14
Project/ModelPurchase.edmx.diagram
Normal file
14
Project/ModelPurchase.edmx.diagram
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram DiagramId="8af6bb3e93b443e58e9543de2aff0f09" Name="Diagram1">
|
||||
<EntityTypeShape EntityType="EEModel.Items" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModel.Purchase" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="EEModel.vPurchase" Width="1.5" PointX="5.375" PointY="0.75" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
||||
733
Project/ModelPurchase.tt
Normal file
733
Project/ModelPurchase.tt
Normal file
@@ -0,0 +1,733 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"ModelPurchase.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
WriteHeader(codeStringGenerator, fileManager);
|
||||
|
||||
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(entity.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||
{
|
||||
<#
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public <#=code.Escape(entity)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var navigationProperty in collectionNavigationProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach (var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(complexProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||
if (navigationProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach (var navigationProperty in navigationProperties)
|
||||
{
|
||||
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(complex.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||
{
|
||||
<#
|
||||
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
public <#=code.Escape(complex)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach(var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var edmProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#
|
||||
if (typeMapper.EnumIsFlags(enumType))
|
||||
{
|
||||
#>
|
||||
[Flags]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||
{
|
||||
<#
|
||||
var foundOne = false;
|
||||
|
||||
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||
{
|
||||
foundOne = true;
|
||||
#>
|
||||
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||
<#
|
||||
}
|
||||
|
||||
if (foundOne)
|
||||
{
|
||||
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
fileManager.Process();
|
||||
|
||||
#>
|
||||
<#+
|
||||
|
||||
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||
{
|
||||
fileManager.StartHeader();
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||
<#+
|
||||
fileManager.EndBlock();
|
||||
}
|
||||
|
||||
public void BeginNamespace(CodeGenerationTools code)
|
||||
{
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#+
|
||||
PushIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndNamespace(CodeGenerationTools code)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
69
Project/Projects.cs
Normal file
69
Project/Projects.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Projects
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public Nullable<int> pidx { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public Nullable<bool> isdel { get; set; }
|
||||
public string category { get; set; }
|
||||
public string status { get; set; }
|
||||
public string asset { get; set; }
|
||||
public Nullable<int> level { get; set; }
|
||||
public Nullable<int> rev { get; set; }
|
||||
public string process { get; set; }
|
||||
public string part { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string name { get; set; }
|
||||
public string userManager { get; set; }
|
||||
public string usermain { get; set; }
|
||||
public string usersub { get; set; }
|
||||
public string userhw2 { get; set; }
|
||||
public string reqstaff { get; set; }
|
||||
public Nullable<double> costo { get; set; }
|
||||
public Nullable<double> costn { get; set; }
|
||||
public Nullable<int> cnt { get; set; }
|
||||
public string remark_req { get; set; }
|
||||
public string remark_ans { get; set; }
|
||||
public string sdate { get; set; }
|
||||
public string ddate { get; set; }
|
||||
public string edate { get; set; }
|
||||
public string odate { get; set; }
|
||||
public Nullable<int> progress { get; set; }
|
||||
public string memo { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
public string orderno { get; set; }
|
||||
public string crdue { get; set; }
|
||||
public Nullable<bool> import { get; set; }
|
||||
public string path { get; set; }
|
||||
public string userprocess { get; set; }
|
||||
public string CMP_Background { get; set; }
|
||||
public string CMP_Description { get; set; }
|
||||
public string CMP_Before { get; set; }
|
||||
public string CMP_After { get; set; }
|
||||
public Nullable<bool> bCost { get; set; }
|
||||
public Nullable<bool> bFanOut { get; set; }
|
||||
public string div { get; set; }
|
||||
public string EB_Site { get; set; }
|
||||
public string EB_Line { get; set; }
|
||||
public string EB_Team { get; set; }
|
||||
public string EB_Model { get; set; }
|
||||
public string EB_OutSourceName { get; set; }
|
||||
public Nullable<double> EB_RepairTime { get; set; }
|
||||
public Nullable<double> EB_ConstNew { get; set; }
|
||||
public string EB_BoardName { get; set; }
|
||||
}
|
||||
}
|
||||
27
Project/ProjectsHistory.cs
Normal file
27
Project/ProjectsHistory.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ProjectsHistory
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public int pidx { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string div { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string remark2 { get; set; }
|
||||
public Nullable<bool> mailsend { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
26
Project/ProjectsIOMap.cs
Normal file
26
Project/ProjectsIOMap.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ProjectsIOMap
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public Nullable<int> Project { get; set; }
|
||||
public string Dir { get; set; }
|
||||
public string PIn { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
27
Project/ProjectsMailList.cs
Normal file
27
Project/ProjectsMailList.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ProjectsMailList
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public Nullable<int> Project { get; set; }
|
||||
public Nullable<bool> enable { get; set; }
|
||||
public string div { get; set; }
|
||||
public string name { get; set; }
|
||||
public string address { get; set; }
|
||||
public string memo { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
}
|
||||
}
|
||||
50
Project/ProjectsPart.cs
Normal file
50
Project/ProjectsPart.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ProjectsPart
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public Nullable<int> no { get; set; }
|
||||
public Nullable<int> Project { get; set; }
|
||||
public string ItemGroup { get; set; }
|
||||
public string ItemModel { get; set; }
|
||||
public string ItemUnit { get; set; }
|
||||
public string ItemName { get; set; }
|
||||
public string ItemSid { get; set; }
|
||||
public string ItemSupply { get; set; }
|
||||
public Nullable<int> ItemSupplyidx { get; set; }
|
||||
public string ItemManu { get; set; }
|
||||
public Nullable<int> Item { get; set; }
|
||||
public string option1 { get; set; }
|
||||
public string option2 { get; set; }
|
||||
public string option3 { get; set; }
|
||||
public Nullable<int> qty { get; set; }
|
||||
public Nullable<int> qtyn { get; set; }
|
||||
public Nullable<decimal> price { get; set; }
|
||||
public Nullable<decimal> amt { get; set; }
|
||||
public Nullable<decimal> amtn { get; set; }
|
||||
public Nullable<int> jago { get; set; }
|
||||
public string remark { get; set; }
|
||||
public string memo { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
public Nullable<bool> import { get; set; }
|
||||
public string qtyjago { get; set; }
|
||||
public Nullable<int> qtybuy { get; set; }
|
||||
public Nullable<int> qtyin { get; set; }
|
||||
public Nullable<bool> bbuy { get; set; }
|
||||
public Nullable<bool> bconfirm { get; set; }
|
||||
public Nullable<bool> bCancel { get; set; }
|
||||
}
|
||||
}
|
||||
52
Project/Purchase.cs
Normal file
52
Project/Purchase.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Purchase
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string state { get; set; }
|
||||
public string process { get; set; }
|
||||
public string receive { get; set; }
|
||||
public string sc { get; set; }
|
||||
public string request { get; set; }
|
||||
public string sid { get; set; }
|
||||
public string pumname { get; set; }
|
||||
public Nullable<int> pumidx { get; set; }
|
||||
public string pumscale { get; set; }
|
||||
public string pumunit { get; set; }
|
||||
public Nullable<int> pumqty { get; set; }
|
||||
public Nullable<decimal> pumprice { get; set; }
|
||||
public Nullable<decimal> pumamt { get; set; }
|
||||
public string supply { get; set; }
|
||||
public Nullable<int> supplyidx { get; set; }
|
||||
public string project { get; set; }
|
||||
public Nullable<int> projectidx { get; set; }
|
||||
public string asset { get; set; }
|
||||
public string manuproc { get; set; }
|
||||
public string edate { get; set; }
|
||||
public string indate { get; set; }
|
||||
public string po { get; set; }
|
||||
public string dept { get; set; }
|
||||
public string bigo { get; set; }
|
||||
public Nullable<bool> import { get; set; }
|
||||
public Nullable<bool> isdel { get; set; }
|
||||
public string orderno { get; set; }
|
||||
public string place { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
public Nullable<int> inqty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@
|
||||
<add name="EEEntities1" connectionString="metadata=res://*/ModelMain.csdl|res://*/ModelMain.ssdl|res://*/ModelMain.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;user id=eeuser;password=Amkor123!;connect timeout=30;encrypt=False;trustservercertificate=False;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="EEEntitiesMain" connectionString="metadata=res://*/AdoNetEFMain.csdl|res://*/AdoNetEFMain.ssdl|res://*/AdoNetEFMain.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;user id=eeuser;password=Amkor123!;connect timeout=30;encrypt=False;trustservercertificate=False;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="S1ACCESS300Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=10.141.18.50;initial catalog=S1ACCESS300;persist security info=True;user id=amkoruser;password=AmkorUser!;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="EEEntitiesPurchase" connectionString="metadata=res://*/ModelPurchase.csdl|res://*/ModelPurchase.ssdl|res://*/ModelPurchase.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;persist security info=True;user id=eeuser;password=Amkor123!;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="EEEntitiesCommon" connectionString="metadata=res://*/ModelCommon.csdl|res://*/ModelCommon.ssdl|res://*/ModelCommon.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;persist security info=True;user id=eeuser;password=Amkor123!;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="EEEntitiesJobreport" connectionString="metadata=res://*/ModelJobreport.csdl|res://*/ModelJobreport.ssdl|res://*/ModelJobreport.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;persist security info=True;user id=eeuser;password=Amkor123!;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="EEEntitiesProject" connectionString="metadata=res://*/ModelProject.csdl|res://*/ModelProject.ssdl|res://*/ModelProject.msl;provider=System.Data.SqlClient;provider connection string="data source=10.131.15.18;initial catalog=EE;persist security info=True;user id=eeuser;password=Amkor123!;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
</connectionStrings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
@@ -37,4 +41,4 @@
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
35
Project/vJobReportForUser.cs
Normal file
35
Project/vJobReportForUser.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class vJobReportForUser
|
||||
{
|
||||
public int idx { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string process { get; set; }
|
||||
public string type { get; set; }
|
||||
public string svalue { get; set; }
|
||||
public Nullable<double> hrs { get; set; }
|
||||
public Nullable<double> ot { get; set; }
|
||||
public string requestpart { get; set; }
|
||||
public string package { get; set; }
|
||||
public string userProcess { get; set; }
|
||||
public string status { get; set; }
|
||||
public string projectName { get; set; }
|
||||
public string description { get; set; }
|
||||
public string ww { get; set; }
|
||||
}
|
||||
}
|
||||
53
Project/vPurchase.cs
Normal file
53
Project/vPurchase.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 템플릿에서 생성되었습니다.
|
||||
//
|
||||
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
|
||||
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Project
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class vPurchase
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int idx { get; set; }
|
||||
public string gcode { get; set; }
|
||||
public string pdate { get; set; }
|
||||
public string state { get; set; }
|
||||
public string process { get; set; }
|
||||
public string receive { get; set; }
|
||||
public string sc { get; set; }
|
||||
public string request { get; set; }
|
||||
public string sid { get; set; }
|
||||
public string pumname { get; set; }
|
||||
public Nullable<int> pumidx { get; set; }
|
||||
public string pumscale { get; set; }
|
||||
public string pumunit { get; set; }
|
||||
public Nullable<int> pumqty { get; set; }
|
||||
public Nullable<decimal> pumprice { get; set; }
|
||||
public Nullable<decimal> pumamt { get; set; }
|
||||
public string supply { get; set; }
|
||||
public Nullable<int> supplyidx { get; set; }
|
||||
public string project { get; set; }
|
||||
public Nullable<int> projectidx { get; set; }
|
||||
public string asset { get; set; }
|
||||
public string manuproc { get; set; }
|
||||
public string edate { get; set; }
|
||||
public string indate { get; set; }
|
||||
public string po { get; set; }
|
||||
public string dept { get; set; }
|
||||
public string bigo { get; set; }
|
||||
public Nullable<bool> import { get; set; }
|
||||
public Nullable<bool> isdel { get; set; }
|
||||
public string orderno { get; set; }
|
||||
public string place { get; set; }
|
||||
public string wuid { get; set; }
|
||||
public System.DateTime wdate { get; set; }
|
||||
public Nullable<int> inqty { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user