Initial checkin from local repository

This commit is contained in:
Alex Hyett 2015-09-20 21:04:10 +01:00
parent 23e9fed246
commit 0c052a7bb2
64 changed files with 159259 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
PlayDrone2SQL/bin/*
PlayDrone2SQL/obj/*
.vs/*
.suo

22
PlayDrone2SQL.sln Normal file
View file

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayDrone2SQL", "PlayDrone2SQL\PlayDrone2SQL.csproj", "{A0D40B32-F188-4DC1-B1A0-03ACB8313803}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0D40B32-F188-4DC1-B1A0-03ACB8313803}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0D40B32-F188-4DC1-B1A0-03ACB8313803}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0D40B32-F188-4DC1-B1A0-03ACB8313803}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0D40B32-F188-4DC1-B1A0-03ACB8313803}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

13
PlayDrone2SQL/App.config Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<connectionStrings>
<add name="MarketDbContainer" connectionString="metadata=res://*/Repository.MarketDb.csdl|res://*/Repository.MarketDb.ssdl|res://*/Repository.MarketDb.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=PlayMarket;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
<add name="MarketDbConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=PlayMarket;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>

View file

@ -0,0 +1,98 @@

namespace PlayDrone2SQL
{
using Models;
using System;
using System.Collections.Generic;
/// <summary>
/// The logger.
/// </summary>
public class AppLogger : IWriter<App>, IReader
{
/// <summary>
/// The writer.
/// </summary>
private readonly IWriter<App> writer;
/// <summary>
/// The reader.
/// </summary>
private IReader reader;
/// <summary>
/// The logger.
/// </summary>
private readonly ILogger log;
public AppLogger(IWriter<App> writer, IReader reader, ILogger log)
{
this.writer = writer;
this.reader = reader;
this.log = log;
}
/// <summary>
/// Logs at the start and end of an app save.
/// </summary>
/// <param name="app">
/// The app to save.
/// </param>
public void Save(App app)
{
log.LogOperation(string.Format("Starting save of app: {0}.", app.app_id));
writer.Save(app);
log.LogOperation(string.Format("Finished save of app: {0}.", app.app_id));
}
/// <summary>
/// Logs at the start and end of saving many apps.
/// </summary>
/// <param name="apps">
/// A list of apps to save.
/// </param>
public void SaveMany(List<App> apps)
{
apps.ForEach(i => log.LogOperation(string.Format("Starting save of app: {0}.", i.app_id)));
writer.SaveMany(apps);
apps.ForEach(i => log.LogOperation(string.Format("Finished save of app: {0}.", i.app_id)));
}
/// <summary>
/// Count the apps using the reader.
/// </summary>
/// <returns></returns>
public int Count()
{
return reader.Count();
}
/// <summary>
/// Get the id of the app from it's unique name.
/// </summary>
/// <param name="name">
/// The name of the app.
/// </param>
/// <returns>
/// The unique identifier.
/// </returns>
public Guid GetId(string name)
{
return reader.GetId(name);
}
/// <summary>
/// Check to see if an app with the given unique name exists.
/// </summary>
/// <param name="name">
/// The name of the app.
/// </param>
/// <returns>
/// True if it exists.
/// </returns>
public bool Exists(string name)
{
return reader.Exists(name);
}
}
}

176
PlayDrone2SQL/AppStore.cs Normal file
View file

@ -0,0 +1,176 @@

namespace PlayDrone2SQL
{
using Repository;
using SqlBulkCopyExample;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using Models;
/// <summary>
/// Store the app using SQL.
/// </summary>
public class AppStore: IWriter<Models.App>, IReader
{
private SqlBulkCopy bulkCopy;
private SqlConnection connection;
/// <summary>
/// App Store constructor
/// </summary>
/// <param name="log">
/// The logger.
/// </param>
/// <param name="connection">
/// A SQL connection.
/// </param>
public AppStore(SqlConnection connection)
{
this.connection = connection;
bulkCopy = new SqlBulkCopy(connection);
bulkCopy.BulkCopyTimeout = 300;
// Open the connection if it isn't open yet.
if (connection.State != System.Data.ConnectionState.Open)
{
connection.Open();
}
MapModelToDb();
}
/// <summary>
/// Persist a list of apps to the database.
/// </summary>
/// <param name="apps">
/// A list of apps to save.
/// </param>
public void SaveMany(List<Models.App> apps)
{
using (var dataReader = new ObjectDataReader<Models.App>(apps))
{
bulkCopy.WriteToServer(dataReader);
}
}
/// <summary>
/// Persist an app to the database.
/// </summary>
/// <param name="app">
/// The app to save.
/// </param>
public void Save(Models.App app)
{
using (var db = new MarketDbContainer())
{
db.Apps.Add(Map(app));
db.SaveChanges();
}
}
/// <summary>
/// Count the apps in the database.
/// </summary>
/// <returns>
/// The number of apps in the database.
/// </returns>
public int Count()
{
using (var db = new MarketDbContainer())
{
return db.Apps.Count();
}
}
/// <summary>
/// Get the app id.
/// </summary>
/// <param name="name">
/// The unique name of the app.
/// </param>
/// <returns>
/// The unque identifier for the app.
/// </returns>
public Guid GetId(string name)
{
using (var db = new MarketDbContainer())
{
return db.Apps.Single(c => c.AppId == name).Id;
}
}
/// <summary>
/// Check to see if the app exists.
/// </summary>
/// <param name="name">
/// The unique name of the app.
/// </param>
/// <returns>
/// True if the app exists.
/// </returns>
public bool Exists(string name)
{
using (var db = new MarketDbContainer())
{
return db.Apps.Any(c => c.AppId == name);
}
}
/// <summary>
/// Map the Model to the database columns.
/// </summary>
private void MapModelToDb()
{
// TODO: Improve by using reflection
bulkCopy.DestinationTableName = "Apps";
bulkCopy.ColumnMappings.Add("id", "Id");
bulkCopy.ColumnMappings.Add("app_id", "AppId");
bulkCopy.ColumnMappings.Add("apk_url", "ApkUrl");
bulkCopy.ColumnMappings.Add("categoryId", "Category");
bulkCopy.ColumnMappings.Add("developer_name", "DeveloperName");
bulkCopy.ColumnMappings.Add("downloads", "Downloads");
bulkCopy.ColumnMappings.Add("free", "Free");
bulkCopy.ColumnMappings.Add("installation_size", "InstallationSize");
bulkCopy.ColumnMappings.Add("metadata_url", "MetadataUrl");
bulkCopy.ColumnMappings.Add("snapshot_date", "SnapshotDate");
bulkCopy.ColumnMappings.Add("star_rating", "StarRating");
bulkCopy.ColumnMappings.Add("title", "Title");
bulkCopy.ColumnMappings.Add("version_code", "VersionCode");
bulkCopy.ColumnMappings.Add("version_string", "VersionString");
}
/// <summary>
/// Map app model to entity model.
/// </summary>
/// <param name="app">
/// The app model.
/// </param>
/// <returns>
/// The app entity model.
/// </returns>
private Repository.App Map(Models.App app)
{
return new Repository.App
{
Id = (Guid)app.id,
AppId = app.app_id,
ApkUrl = app.apk_url,
Category = (Guid)app.categoryId,
DeveloperName = app.developer_name,
Downloads = app.downloads,
Free = app.free,
InstallationSize = app.installation_size,
MetadataUrl = app.metadata_url,
SnapshotDate = app.snapshot_date,
StarRating = app.star_rating,
Title = app.title,
VersionCode = app.version_code,
VersionString = app.version_string
};
}
}
}

View file

@ -0,0 +1,79 @@

namespace PlayDrone2SQL
{
using Models;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
public class CategoryCache : IWriter<Category>, IReader
{
private Dictionary<string, Guid> categoryLookup = new Dictionary<string, Guid>();
private IWriter<Category> writer;
private IReader reader;
public CategoryCache(IWriter<Category> writer, IReader reader)
{
this.writer = writer;
this.reader = reader;
}
public int Count()
{
if(categoryLookup.Any())
{
return categoryLookup.Count();
}
return reader.Count();
}
public bool Exists(string name)
{
var exists = categoryLookup.ContainsKey(name);
if (!exists)
{
exists = reader.Exists(name);
}
return exists;
}
public Guid GetId(string name)
{
var exists = categoryLookup.ContainsKey(name);
if(!exists)
{
return reader.GetId(name);
}
return categoryLookup[name];
}
public void Save(Category category)
{
if(!categoryLookup.ContainsKey(category.Name))
{
categoryLookup.Add(category.Name, category.Id);
}
writer.Save(category);
}
public void SaveMany(List<Category> categories)
{
foreach(var category in categories)
{
if (!categoryLookup.ContainsKey(category.Name))
{
categoryLookup.Add(category.Name, category.Id);
}
}
writer.SaveMany(categories);
}
}
}

View file

@ -0,0 +1,51 @@

namespace PlayDrone2SQL
{
using System.Collections.Generic;
using Models;
using System;
public class CategoryLogger : IWriter<Category>, IReader
{
private IWriter<Category> writer;
private IReader reader;
private ILogger log;
public CategoryLogger(IWriter<Category> writer, IReader reader, ILogger log)
{
this.writer = writer;
this.log = log;
this.reader = reader;
}
public void Save(Category category)
{
log.LogOperation(string.Format("Starting save of category: {0}.", category.Name));
writer.Save(category);
log.LogOperation(string.Format("Finished save of category: {0}.", category.Name));
}
public void SaveMany(List<Category> categories)
{
categories.ForEach(i => log.LogOperation(string.Format("Starting save of category: {0}.", i.Name)));
writer.SaveMany(categories);
categories.ForEach(i => log.LogOperation(string.Format("Finished save of category: {0}.", i.Name)));
}
public int Count()
{
return reader.Count();
}
public Guid GetId(string name)
{
return reader.GetId(name);
}
public bool Exists(string name)
{
return reader.Exists(name);
}
}
}

View file

@ -0,0 +1,112 @@

namespace PlayDrone2SQL
{
using System;
using System.Collections.Generic;
using System.Linq;
using Repository;
/// <summary>
/// The SQL category store.
/// </summary>
public class CategoryStore : IWriter<Models.Category>, IReader
{
/// <summary>
/// Count the categories on the database.
/// </summary>
/// <returns>
/// The number of categories.
/// </returns>
public int Count()
{
using (var db = new MarketDbContainer())
{
return db.Categories.Count();
}
}
/// <summary>
/// Check to see if the category exists.
/// </summary>
/// <param name="name">
/// The name of the category.
/// </param>
/// <returns>
/// True if the category exists.
/// </returns>
public bool Exists(string name)
{
using (var db = new MarketDbContainer())
{
return db.Categories.Any(c => c.Name == name);
}
}
/// <summary>
/// Get the unique if of the category.
/// </summary>
/// <param name="name">
/// The name of the category.
/// </param>
/// <returns>
/// The id of the category.
/// </returns>
public Guid GetId(string name)
{
using (var db = new MarketDbContainer())
{
return db.Categories.Single(c => c.Name == name).Id;
}
}
/// <summary>
/// Save the category.
/// </summary>
/// <param name="category">
/// The category to save.
/// </param>
public void Save(Models.Category category)
{
using (var db = new MarketDbContainer())
{
db.Categories.Add(Map(category));
db.SaveChanges();
}
}
/// <summary>
/// Save a list of categories.
/// </summary>
/// <param name="categories">
/// The categories to save.
/// </param>
public void SaveMany(List<Models.Category> categories)
{
using (var db = new MarketDbContainer())
{
var repoCategories = categories.Select(x => Map(x));
db.Categories.AddRange(repoCategories);
db.SaveChanges();
}
}
/// <summary>
/// Map the category model to the repository model.
/// </summary>
/// <param name="category">
/// The category to map.
/// </param>
/// <returns>
/// The repository category model.
/// </returns>
private Category Map(Models.Category category)
{
return new Repository.Category
{
Id = category.Id,
Name = category.Name
};
}
}
}

View file

@ -0,0 +1,41 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace PlayDrone2SQL
{
public class FileReader
{
private Logger log;
public FileReader(Logger log)
{
this.log = log;
}
public List<Models.App> FileToModel(string filePath)
{
if(string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException("filePath");
}
if(!File.Exists(filePath))
{
throw new ArgumentException(string.Format("File '{0}' does not exist.", filePath));
}
log.LogOperation("Starting reading file.");
var fileContents = File.ReadAllText(filePath);
log.LogOperation("Finished reading file.");
log.LogOperation("Starting deserialisation of file.");
var apps = JsonConvert.DeserializeObject<List<Models.App>>(fileContents);
log.LogOperation(string.Format("Finished deserialisation of file. {0} apps found.", apps.Count()));
return apps;
}
}
}

7
PlayDrone2SQL/ILogger.cs Normal file
View file

@ -0,0 +1,7 @@
namespace PlayDrone2SQL
{
public interface ILogger
{
void LogOperation(string message);
}
}

13
PlayDrone2SQL/IReader.cs Normal file
View file

@ -0,0 +1,13 @@

namespace PlayDrone2SQL
{
using System;
public interface IReader
{
int Count();
Guid GetId(string name);
bool Exists(string name);
}
}

23
PlayDrone2SQL/IWriter.cs Normal file
View file

@ -0,0 +1,23 @@
namespace PlayDrone2SQL
{
using System.Collections.Generic;
public interface IWriter<T>
{
/// <summary>
/// Save an item.
/// </summary>
/// <param name="item">
/// The item to save.
/// </param>
void Save(T item);
/// <summary>
/// Save many items.
/// </summary>
/// <param name="items">
/// The items to save.
/// </param>
void SaveMany(List<T> items);
}
}

16
PlayDrone2SQL/Logger.cs Normal file
View file

@ -0,0 +1,16 @@

namespace PlayDrone2SQL
{
using System;
public class Logger: ILogger
{
/// <summary>
/// Log a to the console.
/// </summary>
/// <param name="message"></param>
public void LogOperation(string message)
{
Console.WriteLine(message);
}
}
}

View file

@ -0,0 +1,86 @@

namespace PlayDrone2SQL.Models
{
using System;
/// <summary>
/// A model of the app in the PlayDrone Json file.
/// </summary>
public class App
{
/// <summary>
/// A unique identifier for the app.
/// </summary>
public Guid? id { get; set; }
/// <summary>
/// The Google ID for the app.
/// </summary>
public string app_id { get; set; }
/// <summary>
/// The title of the app.
/// </summary>
public string title { get; set; }
/// <summary>
/// The name of the developer.
/// </summary>
public string developer_name { get; set; }
/// <summary>
/// The category name.
/// </summary>
public string category { get; set; }
/// <summary>
/// The category id.
/// </summary>
public Guid? categoryId { get; set; }
/// <summary>
/// A flag indicating if the app is free.
/// </summary>
public bool free { get; set; }
/// <summary>
/// The version number.
/// </summary>
public long version_code { get; set; }
/// <summary>
/// The version string.
/// </summary>
public string version_string { get; set; }
/// <summary>
/// The size of the installed app.
/// </summary>
public long installation_size { get; set; }
/// <summary>
/// The number of downloads.
/// </summary>
public long downloads { get; set; }
/// <summary>
/// The average star rating.
/// </summary>
public float star_rating { get; set; }
/// <summary>
/// The date the snapshot was taken.
/// </summary>
public DateTime snapshot_date { get; set; }
/// <summary>
/// The URL of the additional Json data file.
/// </summary>
public string metadata_url { get; set; }
/// <summary>
/// The URL of the apk for the app.
/// </summary>
public string apk_url { get; set; }
}
}

View file

@ -0,0 +1,21 @@

namespace PlayDrone2SQL.Models
{
using System;
/// <summary>
/// The category model.
/// </summary>
public class Category
{
/// <summary>
/// The category id.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// The category name.
/// </summary>
public string Name { get; set; }
}
}

View file

@ -0,0 +1,288 @@
namespace SqlBulkCopyExample
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
/// <summary>
/// Object Data Reader from developerFusion
/// http://www.developerfusion.com/article/122498/using-sqlbulkcopy-for-high-performance-inserts/
/// </summary>
/// <typeparam name="TData"></typeparam>
public class ObjectDataReader<TData> : IDataReader
{
/// <summary>
/// The enumerator for the IEnumerable{TData} passed to the constructor for
/// this instance.
/// </summary>
private IEnumerator<TData> dataEnumerator;
/// <summary>
/// The lookup of accessor functions for the properties on the TData type.
/// </summary>
private Func<TData, object>[] accessors;
/// <summary>
/// The lookup of property names against their ordinal positions.
/// </summary>
private Dictionary<string, int> ordinalLookup;
/// <summary>
/// Initializes a new instance of the <see cref="ObjectDataReader&lt;TData&gt;"/> class.
/// </summary>
/// <param name="data">The data this instance should enumerate through.</param>
public ObjectDataReader(IEnumerable<TData> data)
{
this.dataEnumerator = data.GetEnumerator();
// Get all the readable properties for the class and
// compile an expression capable of reading it
var propertyAccessors = typeof(TData)
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p => p.CanRead)
.Select((p, i) => new
{
Index = i,
Property = p,
Accessor = CreatePropertyAccessor(p)
})
.ToArray();
this.accessors = propertyAccessors.Select(p => p.Accessor).ToArray();
this.ordinalLookup = propertyAccessors.ToDictionary(
p => p.Property.Name,
p => p.Index,
StringComparer.OrdinalIgnoreCase);
}
/// <summary>
/// Creates a property accessor for the given property information.
/// </summary>
/// <param name="p">The property information to generate the accessor for.</param>
/// <returns>The generated accessor function.</returns>
private Func<TData, object> CreatePropertyAccessor(PropertyInfo p)
{
// Define the parameter that will be passed - will be the current object
var parameter = Expression.Parameter(typeof(TData), "input");
// Define an expression to get the value from the property
var propertyAccess = Expression.Property(parameter, p.GetGetMethod());
// Make sure the result of the get method is cast as an object
var castAsObject = Expression.TypeAs(propertyAccess, typeof(object));
// Create a lambda expression for the property access and compile it
var lamda = Expression.Lambda<Func<TData, object>>(castAsObject, parameter);
return lamda.Compile();
}
#region IDataReader Members
public void Close()
{
this.Dispose();
}
public int Depth
{
get { return 1; }
}
public DataTable GetSchemaTable()
{
return null;
}
public bool IsClosed
{
get { return this.dataEnumerator == null; }
}
public bool NextResult()
{
return false;
}
public bool Read()
{
if (this.dataEnumerator == null)
{
throw new ObjectDisposedException("ObjectDataReader");
}
return this.dataEnumerator.MoveNext();
}
public int RecordsAffected
{
get { return -1; }
}
#endregion
#region IDisposable Members
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
if (disposing)
{
if (this.dataEnumerator != null)
{
this.dataEnumerator.Dispose();
this.dataEnumerator = null;
}
}
}
#endregion
#region IDataRecord Members
public int FieldCount
{
get { return this.accessors.Length; }
}
public bool GetBoolean(int i)
{
throw new NotImplementedException();
}
public byte GetByte(int i)
{
throw new NotImplementedException();
}
public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
{
throw new NotImplementedException();
}
public char GetChar(int i)
{
throw new NotImplementedException();
}
public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
{
throw new NotImplementedException();
}
public IDataReader GetData(int i)
{
throw new NotImplementedException();
}
public string GetDataTypeName(int i)
{
throw new NotImplementedException();
}
public DateTime GetDateTime(int i)
{
throw new NotImplementedException();
}
public decimal GetDecimal(int i)
{
throw new NotImplementedException();
}
public double GetDouble(int i)
{
throw new NotImplementedException();
}
public Type GetFieldType(int i)
{
throw new NotImplementedException();
}
public float GetFloat(int i)
{
throw new NotImplementedException();
}
public Guid GetGuid(int i)
{
throw new NotImplementedException();
}
public short GetInt16(int i)
{
throw new NotImplementedException();
}
public int GetInt32(int i)
{
throw new NotImplementedException();
}
public long GetInt64(int i)
{
throw new NotImplementedException();
}
public string GetName(int i)
{
throw new NotImplementedException();
}
public int GetOrdinal(string name)
{
int ordinal;
if (!this.ordinalLookup.TryGetValue(name, out ordinal))
{
throw new InvalidOperationException("Unknown parameter name " + name);
}
return ordinal;
}
public string GetString(int i)
{
throw new NotImplementedException();
}
public object GetValue(int i)
{
if (this.dataEnumerator == null)
{
throw new ObjectDisposedException("ObjectDataReader");
}
return this.accessors[i](this.dataEnumerator.Current);
}
public int GetValues(object[] values)
{
throw new NotImplementedException();
}
public bool IsDBNull(int i)
{
throw new NotImplementedException();
}
public object this[string name]
{
get { throw new NotImplementedException(); }
}
public object this[int i]
{
get { throw new NotImplementedException(); }
}
#endregion
}
}

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A0D40B32-F188-4DC1-B1A0-03ACB8313803}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PlayDrone2SQL</RootNamespace>
<AssemblyName>PlayDrone2SQL</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppLogger..cs" />
<Compile Include="CategoryCache.cs" />
<Compile Include="CategoryLogger.cs" />
<Compile Include="FileReader.cs" />
<Compile Include="AppStore.cs" />
<Compile Include="CategoryStore.cs" />
<Compile Include="ILogger.cs" />
<Compile Include="IReader.cs" />
<Compile Include="IWriter.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Models\App.cs" />
<Compile Include="Models\Category.cs" />
<Compile Include="ObjectDataReader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repository\App.cs">
<DependentUpon>MarketDb.tt</DependentUpon>
</Compile>
<Compile Include="Repository\Category.cs">
<DependentUpon>MarketDb.tt</DependentUpon>
</Compile>
<Compile Include="Repository\MarketDb.Context.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>MarketDb.Context.tt</DependentUpon>
</Compile>
<Compile Include="Repository\MarketDb.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>MarketDb.tt</DependentUpon>
</Compile>
<Compile Include="Repository\MarketDb.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>MarketDb.edmx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<EntityDeploy Include="Repository\MarketDb.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>MarketDb.Designer.cs</LastGenOutput>
</EntityDeploy>
<None Include="Repository\MarketDb.edmx.diagram">
<DependentUpon>MarketDb.edmx</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Repository\MarketDb.Context.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MarketDb.Context.cs</LastGenOutput>
<DependentUpon>MarketDb.edmx</DependentUpon>
</Content>
<Content Include="Repository\MarketDb.edmx.sql" />
<Content Include="Repository\MarketDb.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MarketDb.cs</LastGenOutput>
<DependentUpon>MarketDb.edmx</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>"C:\Users\Alex\Google Drive\Documents\Articles\playsmall.json"</StartArguments>
</PropertyGroup>
</Project>

81
PlayDrone2SQL/Program.cs Normal file
View file

@ -0,0 +1,81 @@
namespace PlayDrone2SQL
{
using System;
using System.Linq;
using System.Configuration;
using System.Data.SqlClient;
using System.Collections.Generic;
public class Program
{
public static void Main(string[] args)
{
string filePath = null;
if (args.Length == 0)
{
throw new ArgumentException("Should be called with a Json PlayDrone file to import.");
}
filePath = args[0];
var log = new Logger();
var appConverter = new FileReader(log);
var apps = appConverter.FileToModel(filePath);
var count = apps.Count();
// Setup connection
var connectionString = ConfigurationManager.ConnectionStrings["MarketDbConnectionString"];
using (var connection = new SqlConnection(connectionString.ConnectionString))
{
// Initialise app store with logger and connection
var appSqlStore = new AppStore(connection);
var appStore = new AppLogger(appSqlStore, appSqlStore, log);
var categorySqlStore = new CategoryStore();
var categoryCacheStore = new CategoryCache(categorySqlStore, categorySqlStore);
var categoryStore = new CategoryLogger(categoryCacheStore, categoryCacheStore, log);
// Assuming apps are added in order to save multiple queries to the database.
var existingAppCount = appStore.Count();
// Loop through apps. App store will save every 100,000 apps
var appsToSave = new List<Models.App>();
var appCounter = 0;
for (int i = existingAppCount; i < count; i++)
{
// Get the app from the list.
var app = apps[i];
// Store the app category if it doesn't exist.
if (!categoryStore.Exists(app.category))
{
var category = new Models.Category { Id = Guid.NewGuid(), Name = app.category };
categoryStore.Save(category);
}
// Lookup app category id.
var categoryId = categoryStore.GetId(app.category);
app.id = Guid.NewGuid();
app.categoryId = categoryId;
appsToSave.Add(app);
log.LogOperation(string.Format("App {0}/{1} added: {2}", i + 1, count, app.app_id));
appCounter++;
// Save apps
if(appCounter >= 100000)
{
appStore.SaveMany(appsToSave);
appsToSave.Clear();
appCounter = 0;
}
}
// Save the remainder
appStore.SaveMany(appsToSave);
log.LogOperation("DONE!!!!");
}
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PlayAnalyser")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlayAnalyser")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a0d40b32-f188-4dc1-b1a0-03acb8313803")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PlayDrone2SQL.Repository
{
using System;
using System.Collections.Generic;
public partial class App
{
public System.Guid Id { get; set; }
public string AppId { get; set; }
public string Title { get; set; }
public string DeveloperName { get; set; }
public System.Guid Category { get; set; }
public bool Free { get; set; }
public long VersionCode { get; set; }
public string VersionString { get; set; }
public long InstallationSize { get; set; }
public long Downloads { get; set; }
public double StarRating { get; set; }
public System.DateTime SnapshotDate { get; set; }
public string MetadataUrl { get; set; }
public string ApkUrl { get; set; }
public virtual Category Category1 { get; set; }
}
}

View file

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PlayDrone2SQL.Repository
{
using System;
using System.Collections.Generic;
public partial class Category
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Category()
{
this.Apps = new HashSet<App>();
}
public System.Guid Id { get; set; }
public string Name { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<App> Apps { get; set; }
}
}

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PlayDrone2SQL.Repository
{
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class MarketDbContainer : DbContext
{
public MarketDbContainer()
: base("name=MarketDbContainer")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<App> Apps { get; set; }
public virtual DbSet<Category> Categories { get; set; }
}
}

View file

@ -0,0 +1,636 @@
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
output extension=".cs"#><#
const string inputFile = @"MarketDb.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);
}
}
#>

View file

@ -0,0 +1,10 @@
// T4 code generation is enabled for model 'D:\Dropbox\Alex\Projects\PlayDrone2SQL\PlayDrone2SQL\Repository\MarketDb.edmx'.
// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
// is open in the designer.
// If no context and entity classes have been generated, it may be because you created an empty model but
// have not yet chosen which version of Entity Framework to use. To generate a context class and entity
// classes for your model, open the model in the designer, right-click on the designer surface, and
// select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
// Item...'.

View file

@ -0,0 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

View file

@ -0,0 +1,163 @@
<?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="MarketDb.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" 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="Apps">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="uniqueidentifier" Nullable="false" />
<Property Name="AppId" Type="nvarchar(max)" Nullable="false" />
<Property Name="Title" Type="nvarchar(max)" Nullable="false" />
<Property Name="DeveloperName" Type="nvarchar(max)" Nullable="false" />
<Property Name="Category" Type="uniqueidentifier" Nullable="false" />
<Property Name="Free" Type="bit" Nullable="false" />
<Property Name="VersionCode" Type="bigint" Nullable="false" />
<Property Name="VersionString" Type="nvarchar(max)" Nullable="false" />
<Property Name="InstallationSize" Type="bigint" Nullable="false" />
<Property Name="Downloads" Type="bigint" Nullable="false" />
<Property Name="StarRating" Type="float" Nullable="false" />
<Property Name="SnapshotDate" Type="datetime" Nullable="false" />
<Property Name="MetadataUrl" Type="nvarchar(max)" Nullable="false" />
<Property Name="ApkUrl" Type="nvarchar(max)" />
</EntityType>
<EntityType Name="Categories">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="uniqueidentifier" Nullable="false" />
<Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>
<Association Name="FK_Apps_Categories">
<End Role="Categories" Type="Self.Categories" Multiplicity="1" />
<End Role="Apps" Type="Self.Apps" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Categories">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="Apps">
<PropertyRef Name="Category" />
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="MarketDbStoreContainer">
<EntitySet Name="Apps" EntityType="Self.Apps" Schema="dbo" store:Type="Tables" />
<EntitySet Name="Categories" EntityType="Self.Categories" Schema="dbo" store:Type="Tables" />
<AssociationSet Name="FK_Apps_Categories" Association="Self.FK_Apps_Categories">
<End Role="Categories" EntitySet="Categories" />
<End Role="Apps" EntitySet="Apps" />
</AssociationSet>
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" Namespace="MarketDb" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" annotation:UseStrongSpatialTypes="false">
<EntityContainer Name="MarketDbContainer" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Apps" EntityType="MarketDb.App" />
<EntitySet Name="Categories" EntityType="MarketDb.Category" />
<AssociationSet Name="FK_Apps_Categories" Association="MarketDb.FK_Apps_Categories">
<End EntitySet="Categories" Role="Category" />
<End EntitySet="Apps" Role="App" />
</AssociationSet>
</EntityContainer>
<EntityType Name="App">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Guid" Nullable="false" annotation:StoreGeneratedPattern="None" />
<Property Name="AppId" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<Property Name="Title" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<Property Name="DeveloperName" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<Property Name="Category" Type="Guid" Nullable="false" />
<Property Name="Free" Type="Boolean" Nullable="false" />
<Property Name="VersionCode" Type="Int64" Nullable="false" />
<Property Name="VersionString" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<Property Name="InstallationSize" Type="Int64" Nullable="false" />
<Property Name="Downloads" Type="Int64" Nullable="false" />
<Property Name="StarRating" Type="Double" Nullable="false" />
<Property Name="SnapshotDate" Type="DateTime" Nullable="false" Precision="3" />
<Property Name="MetadataUrl" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<Property Name="ApkUrl" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
<NavigationProperty Name="Category1" Relationship="MarketDb.FK_Apps_Categories" FromRole="App" ToRole="Category" />
</EntityType>
<EntityType Name="Category">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Guid" Nullable="false" annotation:StoreGeneratedPattern="None" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
<NavigationProperty Name="Apps" Relationship="MarketDb.FK_Apps_Categories" FromRole="Category" ToRole="App" />
</EntityType>
<Association Name="FK_Apps_Categories">
<End Type="MarketDb.Category" Multiplicity="1" Role="Category" />
<End Type="MarketDb.App" Multiplicity="*" Role="App" />
<ReferentialConstraint>
<Principal Role="Category">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="App">
<PropertyRef Name="Category" />
</Dependent>
</ReferentialConstraint>
</Association>
</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="MarketDbStoreContainer" CdmEntityContainer="MarketDbContainer">
<EntitySetMapping Name="Apps">
<EntityTypeMapping TypeName="IsTypeOf(MarketDb.App)">
<MappingFragment StoreEntitySet="Apps">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="AppId" ColumnName="AppId" />
<ScalarProperty Name="Title" ColumnName="Title" />
<ScalarProperty Name="DeveloperName" ColumnName="DeveloperName" />
<ScalarProperty Name="Category" ColumnName="Category" />
<ScalarProperty Name="Free" ColumnName="Free" />
<ScalarProperty Name="VersionCode" ColumnName="VersionCode" />
<ScalarProperty Name="VersionString" ColumnName="VersionString" />
<ScalarProperty Name="InstallationSize" ColumnName="InstallationSize" />
<ScalarProperty Name="Downloads" ColumnName="Downloads" />
<ScalarProperty Name="StarRating" ColumnName="StarRating" />
<ScalarProperty Name="SnapshotDate" ColumnName="SnapshotDate" />
<ScalarProperty Name="MetadataUrl" ColumnName="MetadataUrl" />
<ScalarProperty Name="ApkUrl" ColumnName="ApkUrl" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Categories">
<EntityTypeMapping TypeName="IsTypeOf(MarketDb.Category)">
<MappingFragment StoreEntitySet="Categories">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Name" ColumnName="Name" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping></edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<edmx:Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</edmx:Connection>
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="True" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
<DesignerProperty Name="UseLegacyProvider" Value="False" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
</DesignerInfoPropertySet>
</edmx:Options>
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>

View 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="f52c5869ed13474a9782181bd00b4b95" Name="Diagram1" >
<EntityTypeShape EntityType="MarketDb.App" PointX="2.75" PointY="0.75" Width="1.5" />
<EntityTypeShape EntityType="MarketDb.Category" PointX="0.75" PointY="0.75" Width="1.5" />
<AssociationConnector Association="MarketDb.FK_Apps_Categories" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>

View file

@ -0,0 +1,103 @@
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 08/16/2015 23:13:14
-- Generated from EDMX file: D:\Dropbox\Alex\Projects\PlayDrone2SQL\PlayDrone2SQL\Repository\MarketDb.edmx
-- --------------------------------------------------
SET QUOTED_IDENTIFIER OFF;
GO
USE [PlayMarket];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[FK_AppCategory]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Categories] DROP CONSTRAINT [FK_AppCategory];
GO
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[Apps]', 'U') IS NOT NULL
DROP TABLE [dbo].[Apps];
GO
IF OBJECT_ID(N'[dbo].[Categories]', 'U') IS NOT NULL
DROP TABLE [dbo].[Categories];
GO
-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------
-- Creating table 'Apps'
CREATE TABLE [dbo].[Apps] (
[Id] uniqueidentifier NOT NULL,
[AppId] nvarchar(max) NOT NULL,
[Title] nvarchar(max) NOT NULL,
[DeveloperName] nvarchar(max) NOT NULL,
[Category] uniqueidentifier NOT NULL,
[Free] bit NOT NULL,
[VersionCode] bigint NOT NULL,
[VersionString] nvarchar(max) NOT NULL,
[InstallationSize] bigint NOT NULL,
[Downloads] bigint NOT NULL,
[StarRating] float NOT NULL,
[SnapshotDate] datetime NOT NULL,
[MetadataUrl] nvarchar(max) NOT NULL,
[ApkUrl] nvarchar(max) NULL
);
GO
-- Creating table 'Categories'
CREATE TABLE [dbo].[Categories] (
[Id] uniqueidentifier NOT NULL,
[Name] nvarchar(max) NOT NULL,
[App_Id] uniqueidentifier NOT NULL
);
GO
-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------
-- Creating primary key on [Id] in table 'Apps'
ALTER TABLE [dbo].[Apps]
ADD CONSTRAINT [PK_Apps]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'Categories'
ALTER TABLE [dbo].[Categories]
ADD CONSTRAINT [PK_Categories]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------
-- Creating foreign key on [App_Id] in table 'Categories'
ALTER TABLE [dbo].[Categories]
ADD CONSTRAINT [FK_AppCategory]
FOREIGN KEY ([App_Id])
REFERENCES [dbo].[Apps]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
-- Creating non-clustered index for FOREIGN KEY 'FK_AppCategory'
CREATE INDEX [IX_FK_AppCategory]
ON [dbo].[Categories]
([App_Id]);
GO
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

View file

@ -0,0 +1,733 @@
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
output extension=".cs"#><#
const string inputFile = @"MarketDb.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);
}
}
#>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
</packages>

Binary file not shown.

View file

@ -0,0 +1,5 @@
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
</configuration>

View file

@ -0,0 +1,5 @@
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
</configuration>

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,48 @@
TOPIC
about_EntityFramework
SHORT DESCRIPTION
Provides information about Entity Framework commands.
LONG DESCRIPTION
This topic describes the Entity Framework commands. Entity Framework is
Microsoft's recommended data access technology for new applications.
The following Entity Framework cmdlets are used with Entity Framework
Migrations.
Cmdlet Description
----------------- ---------------------------------------------------
Enable-Migrations Enables Code First Migrations in a project.
Add-Migration Scaffolds a migration script for any pending model
changes.
Update-Database Applies any pending migrations to the database.
Get-Migrations Displays the migrations that have been applied to
the target database.
The following Entity Framework cmdlets are used by NuGet packages that
install Entity Framework providers. These commands are not usually used as
part of normal application development.
Cmdlet Description
------------------------------ ---------------------------------------
Add-EFProvider Adds or updates an Entity Framework
provider entry in the project config
file.
Add-EFDefaultConnectionFactory Adds or updates an Entity Framework
default connection factory in the
project config file.
Initialize-EFConfiguration Initializes the Entity Framework
section in the project config file and
sets defaults.
SEE ALSO
Enable-Migrations
Add-Migration
Update-Database
Get-Migrations

View file

@ -0,0 +1,155 @@
param($installPath, $toolsPath, $package, $project)
if (Get-Module | ?{ $_.Name -eq 'EntityFramework' })
{
Remove-Module EntityFramework
}
Import-Module (Join-Path $toolsPath EntityFramework.psd1)
# SIG # Begin signature block
# MIIa4AYJKoZIhvcNAQcCoIIa0TCCGs0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUjXj4E03IfImYfKMB4CA3DfY0
# KZmgghWCMIIEwzCCA6ugAwIBAgITMwAAAGJBL8dNiq4TJgAAAAAAYjANBgkqhkiG
# 9w0BAQUFADB3MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4G
# A1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSEw
# HwYDVQQDExhNaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EwHhcNMTUwMjEwMTgzMzM3
# WhcNMTYwNTEwMTgzMzM3WjCBszELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hp
# bmd0b24xEDA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MwMjE3Mjk1OFowIwYJ
# KoZIhvcNAQkEMRYEFKxtHfNR1GPWPqo0yuBPiJ3WZNX2MA0GCSqGSIb3DQEBBQUA
# BIIBAAwIulYLc715s8FIBZzA3zKD9IKqlhrzpTNBY014mi1pwl2sMpKyA/xAH4Gj
# eyo4wzSR7PT2BsYEHElYh7tx/eC45rI2mYIFqfsyqbRBxRfWQCb3pb42kix/RUJ+
# ElTkwy7SG6c04KA8Yi/Z3uOxxlBCWfXWupHQMpIsdVI1s/v65Tn3TNyBLtPu507q
# CNcYfok3IIhcvQCd7vCUK2fnJsuLxbFFqqKoMft10iqAROREkXEhfcyLOUt4BrMh
# KN2ygSFPCIbFAGvmS84oq8p4FzJAFUL9rE8qzxzXrbEA4UglDj72mW6nXmXaHiOZ
# J+2fE3M9xcMV3gKEuSL/DiQhPaI=
# SIG # End signature block

View file

@ -0,0 +1,154 @@
param($installPath, $toolsPath, $package, $project)
Initialize-EFConfiguration $project
Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer'
Write-Host
Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework commands."
# SIG # Begin signature block
# MIIa4AYJKoZIhvcNAQcCoIIa0TCCGs0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUt8mwpdjiFmu2B4KBh+vEeQ+V
# VnSgghWCMIIEwzCCA6ugAwIBAgITMwAAAGJBL8dNiq4TJgAAAAAAYjANBgkqhkiG
# 9w0BAQUFADB3MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4G
# A1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSEw
# HwYDVQQDExhNaWNyb3NvZnQgVGltZS1Td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EzMAAABiQS/HTYquEyYAAAAAAGIwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJ
# AzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MDMwMjE3Mjk1OFowIwYJ
# KoZIhvcNAQkEMRYEFAMe6WzqHaLPBigGoS/gaG25ANUpMA0GCSqGSIb3DQEBBQUA
# BIIBAGFxF739EOC9CNxIDxocqE2PugMRxvX1rrmsvfwnrhaZmL9XqeWgsS8SqJq3
# GOASzoTwvkyAE9qavr0o34a84HDSVbapNEribsu6ILaZpd0ucFGbk4L3QcSODtvH
# XZuCh0cl3ohJT8ShQBNmN9TkqlhnP9AYWcoNaefJkozg7xc3m/CsGkcbSHNk0Bvm
# IF1zG1axnKwNFXopJLnbqxqajBcH3VaCTo9cEshs9qaUy2NZ4RZJztYnnBQsGvv8
# go2qsBgLcALFpVHrSX6yKuH8XVwR+lHofY7nZHs0TLi55SFbpJK+53BCWeH4OK85
# wQ6quf2TAX7dc3ct2zrY3TWhf7Q=
# SIG # End signature block

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,112 @@
param($installPath, $toolsPath, $package, $project)
# open json.net splash page on package install
# don't open if json.net is installed as a dependency
try
{
$url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
{
# user is installing from VS NuGet console
# get reference to the window, the console host and the input history
# show webpage if "install-package newtonsoft.json" was last input
$consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
$props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
$prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
if ($prop -eq $null) { return }
$hostInfo = $prop.GetValue($consoleWindow)
if ($hostInfo -eq $null) { return }
$history = $hostInfo.WpfConsole.InputHistory.History
$lastCommand = $history | select -last 1
if ($lastCommand)
{
$lastCommand = $lastCommand.Trim().ToLower()
if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
else
{
# user is installing from VS NuGet dialog
# get reference to the window, then smart output console provider
# show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
$instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
[System.Reflection.BindingFlags]::NonPublic)
$consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($instanceField -eq $null -or $consoleField -eq $null) { return }
$instance = $instanceField.GetValue($null)
if ($instance -eq $null) { return }
$consoleProvider = $consoleField.GetValue($instance)
if ($consoleProvider -eq $null) { return }
$console = $consoleProvider.CreateOutputConsole($false)
$messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($messagesField -eq $null) { return }
$messages = $messagesField.GetValue($console)
if ($messages -eq $null) { return }
$operations = $messages -split "=============================="
$lastOperation = $operations | select -last 1
if ($lastOperation)
{
$lastOperation = $lastOperation.ToLower()
$lines = $lastOperation -split "`r`n"
$installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
if ($installMatch)
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
}
catch
{
try
{
$pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
$selection = $pmPane.TextDocument.Selection
$selection.StartOfDocument($false)
$selection.EndOfDocument($true)
if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
catch
{
# stop potential errors from bubbling up
# worst case the splash page won't open
}
}
# still yolo