bpedziwiatr / datavers-gen-cli Goto Github PK
View Code? Open in Web Editor NEWPower platform dataverse early bound generator based on T4 template as cli with GUI options
License: MIT License
Power platform dataverse early bound generator based on T4 template as cli with GUI options
License: MIT License
Input: EnvironmentVariableDefinition entity to be generated for c# model
output: fields class contains two definitions for schemaName since Schemaname is generated from entity schema name and Schema name field on EnviromentVariableDefinition.
public const string SchemaName = "environmentvariabledefinition";
public const string SchemaName = "schemaname";
suggested fix: rename Schemaname generated from entityname to EntitySchemaName
find a solution to store connection string in secure way without need to remeber of removing security values from config
Generate one file with type for all tables included in generator.
export type DataverseTabels = "account" | "contactn"...;
Example:
{ "Entities": ["account", "contact", "systemuser" ], "ConnectionString": "", "Namespace": "Dataverse.Entities", "OutDirectory": "Entities", "TemplateName": "ProjectTemplate", "TemplateEngine": { "IsSingleOutput": false, "Name": "scriban", "Type": "C#" } }
Change WelcomeXml to meet eslint requirments:
Example:
WelcomeXml = $@"
// ------------------------------------------------------------------------------
//
// This code was generated by a Dataverse-Cli.
// Runtime Version: {assemblyVersion}
// File Version: {assemblyFileVersion.FileVersion}
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// ------------------------------------------------------------------------------";
Add information in console log what entities where found
Cannot implicitly convert type 'Contoso.Dataverse.DataAccess.Entities.Dataverse.SystemUser' to 'System.Collections.Generic.IEnumerable<Contoso.Dataverse.DataAccess.Entities.Dataverse.SystemUser>'. An explicit conversion exists (are you missing a cast?)
add explicit type:
get => (IEnumerable<{{attribute.to_entity.hybrid_name}}>) GetRelatedEntities<{{attribute.to_entity.hybrid_name}}>("{{attribute.schema_name}}",{{attribute.entity_role}});
fix name of files and types generated
{{info.welcome_xml}}
namespace {{ namespace }}
{
public partial class {{entity.hybrid_name}}
{
public class Enums
{
{{for enm in entity.enums}}
public enum {{enm.display_name}}
{
{{for item in enm.items}}
{{if item.name != "is" }}
{{item.name}} = {{item.value}},
{{else}}
{{item.name}}_ = {{item.value}},
{{end}}
{{end}}
}
{{end}}
}
}
}
Example:
return crmQuery.Where(p => p.erpid == erpid && p.company.Name.Equals(companyId)); //this will return error/invalid query
Example thah works:
return crmQuery.Where(p => p.erpid == erpid && p["companyname"].Equals(companyId)); //this will work
What should be possible:
return crmQuery.Where(p => p.erpid == erpid && p.companyName.Equals(companyId)); //this will be equal to example above
for example when you have table names: xxx_table1 and field xxx_table1 you will receive an error from c# that prop name cannot be the same as class name.
Before:
/// <summary>
/// Unique entity name.
/// </summary>
[AttributeLogicalName("schemaname")]
public string SchemaName
{
get => GetAttributeValue<string>("schemaname");
set
{
OnPropertyChanging("SchemaName");
SetAttributeValue("schemaname", value);
OnPropertyChanged("SchemaName");
}
}
After:
/// <summary>
/// Unique entity name.
/// </summary>
[AttributeLogicalName(Fields.SchemaName)]
public string SchemaName
{
get => GetAttributeValue<string>(Fields.SchemaName);
set
{
OnPropertyChanging(Fields.SchemaName);
SetAttributeValue(Fields.SchemaName, value);
OnPropertyChanged(Fields.SchemaName);
}
}
Add to config path to csproj
add generated files to csproj
remove not generated files from csproj
remove not generated files from generated folder
If possible ship it to chocolety repository
Error handling, when you don't have added credentials in the config file.
if attribute has same name as entity, we get error on genrated C#
//ascii art//
Check code with resharper do some preformance improvment with linq
Try To load all entities and then check for those needed from config
The latest version (1.3.0.18) has the incorrect System.Threading.Tasks.Extensions.dll version in the zip file.
Version from the older release works flawlessly.
@C485 working on it,
.net 5 with new sdk
Change config.json to dataversegen.config.json
Description contains line breaks
Remove line breaks from descripotion.
Spamming waiting for connection 1000ms instead of throwing an error like prev version (1.3.1.33 works fine)
Retrieving All Entities
All Entities Retrieved
Retrieving Selected Entities
All Selected Entities Retrieved
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at DataverseGen.Core.Metadata.MappingRelationshipN1.Parse(OneToManyRelationshipMetadata rel, MappingField[] properties)
at DataverseGen.Core.Metadata.MappingEntity.<>c__DisplayClass71_0.<Parse>b__10(OneToManyRelationshipMetadata r)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at DataverseGen.Core.Metadata.MappingEntity.Parse(EntityMetadata entityMetadata)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at DataverseGen.Core.DataConverter.DataverseConnector.GetMappedEntities()
at DataverseGen.Cli.Program.Main(String[] args)
#StackTrace:
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at DataverseGen.Core.Metadata.MappingRelationshipN1.Parse(OneToManyRelationshipMetadata rel, MappingField[] properties)
at DataverseGen.Core.Metadata.MappingEntity.<>c__DisplayClass71_0.<Parse>b__10(OneToManyRelationshipMetadata r)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at DataverseGen.Core.Metadata.MappingEntity.Parse(EntityMetadata entityMetadata)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at DataverseGen.Core.DataConverter.DataverseConnector.GetMappedEntities()
at DataverseGen.Cli.Program.Main(String[] args)
Unhandled Exception: System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at DataverseGen.Core.Metadata.MappingRelationshipN1.Parse(OneToManyRelationshipMetadata rel, MappingField[] properties)
at DataverseGen.Core.Metadata.MappingEntity.<>c__DisplayClass71_0.<Parse>b__10(OneToManyRelationshipMetadata r)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at DataverseGen.Core.Metadata.MappingEntity.Parse(EntityMetadata entityMetadata)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at DataverseGen.Core.DataConverter.DataverseConnector.GetMappedEntities()
at DataverseGen.Cli.Program.Main(String[] args)
Bye Bye, see you next time Press any Key to exit
Remove code to load all entities and search for entities
To simpolify request for metadata
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.