在表格模型上创建物理关系

create a physical relationship on the tabular model

是否可以在不使用 Power BI、Power Pivot 或 Analysis Services 的情况下在表格模型上创建物理关系Table?

更准确地说,我可以通过编码(c#、.net core)和使用包或库来创建物理关系吗?

谢谢

使用此包:Microsoft.AnalysisServices.Tabular 此代码有效:

using Server server = new();
server.Connect(Configuration["ConnectionString:SSAS"]);
var database = server.Databases.FindByName(Constants.SSASDB);
var fromTable = database.Model.Tables.Find("sourceTableName");
var toTable = database.Model.Tables.Find("destinationTableName");
SingleColumnRelationship columnRelationship = new();
columnRelationship.Name = "relationName";
columnRelationship.FromColumn = fromTable.Columns.Find("sourceColumnName");
columnRelationship.ToColumn = toTable.Columns.Find("destinationColumnName");
columnRelationship.FromCardinality = RelationshipEndCardinality.One;
columnRelationship.ToCardinality = RelationshipEndCardinality.Many;
columnRelationship.CrossFilteringBehavior = CrossFilteringBehavior.OneDirection;
columnRelationship.SecurityFilteringBehavior = SecurityFilteringBehavior.OneDirection;
columnRelationship.RelyOnReferentialIntegrity = false;
columnRelationship.IsActive = true;
database.Model.Relationships.Add(columnRelationship);
database.Model.SaveChanges();